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!

Need "IIF" Statement to pick between 3 fields 1

Status
Not open for further replies.

beeorlando

Technical User
Oct 2, 2001
14
US
I need an IIF statement to choose between 3 fields.

Here's what it needs to do:

Field 1
Field 2
Field 3

If there is a date in Field 3, display Field 3
If Field 3 is null, display Field 2
If Field 2 is null, display Field 1

I'm at my wits end and would really appreciate any help offered with this. I've only used formulas choosing between 2 fields in the past....with this I'm in over my head!

Thanks!
 
This should work.

IIf(Field3 Is Null,IIf(Field2 Is Null,Field1,Field2),Field3)

Translated From:

If Field3 is Null Then
If Field 2 is Null Then
Field1
Else
Field2
End
Else
Field3
End
 
Ah, you need use the SWITCH function.

NameOfFieldToShow = SWITCH(ISDATE(FIELD3),"FIELD3",ISNULL(FIELD3),"FIELD2",ISNULL(FIELD2),"FIELD1")

HTH,
John
vb_doc@hotmail.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top