Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If then Statement ? 4

Status
Not open for further replies.

Tronsliver

Technical User
Sep 19, 2000
120
US
I have two fields in a table. I need to check each field for certain combinations and end up with a value. There are two possible entries that can be present.

Field one: "G" or a "S"
Field two: "T" or a "N"



If field one has a "G" and field two has a "T" then the result of the quarry must be "T".

If field one has a "S" and field two has a "N" then the result of the quarry must be "A".

If field one has a "G" and field two is an "N" then the result of the quarry must be "N"

How can I build a quarry to accomplish this..I'm stumped.

Thank You in advance.

 
Try this function:

Value: Switch([FieldOne]="G" And [FieldTwo]="T","T",[FieldOne]="S" And [FieldTwo]="N","A",[FieldOne]="G" And [FieldTwo]="N","N")
 
This answer assumes the following (I know you stated the following above, just reiterating to clarify and make sure I understood correctly):

Field1 may ONLY be "G" or "S"
Field2 may ONLY be "T" or "N"

If my assumptions are true, then the following expression pasted into the query design in a new field will yield the correct results.

[tt]
Expr1: IIf([Field1]="G",IIf([Field2]="T","T","N"),"A")
[/tt]

If the assumptions are not true, then we need to know what to put when Field1 and Field2 have other values.

HTH Joe Miller
joe.miller@flotech.net
 
Balor:

A new function I learned, never saw Switch() before.. Joe Miller
joe.miller@flotech.net
 
Yo Balor,

That one will definately go into the cool code archives.

Thanks,

B-) ljprodev@yahoo.com
ProDev
MS Access Applications
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top