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

IIf Statement problem 1

Status
Not open for further replies.

MA04

Technical User
Dec 21, 2004
162
GB
Hi Guys,

I Can't seem to get my IIF statement correct i am working with 4 fields Say field1, field2, field3, field4.

What i want to do is display field1 and field2 together seperated by a comma if both are not null and field3 or field4 are not null, if field1 is not null and both field3 and field4 is null then display just field1, if field1 is null then display field2, else if field2 is null then dispay field1

this is my iif statement for the above, it has syntax error:
Code:
IIf(IIf(IIf(IsNull(Strd) Or Not IsNull(Locdd & Locd), STRD & IIf(IsNull(STR),'',', ' & STR), IIf(IsNull(STR),'',', ' & STR)) & not IsNull(Strd) Or Not IsNull(Locdd & Locd), STRD & IIf(IsNull(STR),'',', ' & STR), IIf(IsNull(STR),'',', ' & STR))) & not IsNull(Strd) and IsNull(Locdd & Locd), STRD, IIf(IsNull(STR),'',', ' & STR)))

Thanks in advance for any help,
M-.
 
Sorry for poor explanation; field1 = STRD, Field2 = STR, Field3 = Locdd, Field4= Locd

M-.
 
Something like this ?
IIf(Not IsNull(STRD + STR + (Locdd & Locd)), STRD & ',' & STR,
IIf(Not IsNull(STRD) And IsNull(Locdd) And IsNull(Locd),STRD,
Nz(STRD,STR)))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for the reply PH, I will give it a go tomorrow and get back to you if it worked, Looks like what i am looking for though,

M-.
 
Thanks PH, it did the job,

M-.[thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top