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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIF statement and then 3

Status
Not open for further replies.

paul123456

Technical User
Apr 29, 2002
518
US
Does the code go IIF ([table.record]=data [in record] , display this , or else this) And...

i want to be able to make a reference on my report.. my question is the a comma (,) the same as then? and the second (,) is or else?

im trying to pull information for a field...

if it = to CA then display California.. and if it = to TX then display Texes. or else if neither display "your state"


Thanks, PAUL

 
is the comma (,) the same as then? and the second (,) is else?"

Yes. The syntax is iif(expression, true clause, false clause).

iif's can be nested, so the clauses may be other iif's.

So, for the situation you describe, assuming your state field is called STATE:

IIF(STATE="CA","California",IIF(STATE="TX","Texas","your state"))

Note that the else clause of the first iif is another iif.
 
A further extension of the nested IIF statements is the Switch function:

Code:
Switch([i]express_1[/i], True clause,[i]express_2[/i], True clause, [i]express-3[/i], True clause, . . . [n]expressions)

I find the Switch function easier to code and understand when multiple nesting of IIF's. You must put your expressions in order of priority of analysis. If none of the expressions are true then the function returns a Null. So, the last expression should be entered as
Code:
. . True, True clause)

Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top