Nested IIF Statement in a query

F

FrankTimJr

I'm trying to set up a nested IIF statement in a query and I'm striking out.

Basically I'm trying to do the following:

If "Field A" and "Field B" are both blank, "Enter This Text" OR If "Field A"
is NOT blank, "Enter That Text".

Any ideas??
Thanks in adavnce.
Frank
 
S

Stefan Hoffmann

hi Frank,

I'm trying to set up a nested IIF statement in a query and I'm striking out.

Basically I'm trying to do the following:

If "Field A" and "Field B" are both blank, "Enter This Text" OR If "Field A"
is NOT blank, "Enter That Text".
Iif(Len(Trim(Nz([FieldA], ""))) > 0,
"Enter That Text",
Iif(Len(Trim(Nz([FieldB], ""))) = 0), "Enter This Text", "???")

mfG
--> stefan <--
 
A

Allen Browne

You haven't indicated what to do if A is blank and B is not.
Assuming you leave the text blank for this column, perhaps something like
this:

IIf([A] Is Null, IIf( Is Null, "Enter this text", Null), "Enter that
text")
 
D

Daryl S

Frank -

You didn't say what the result should be for when A is null and B is not, so
I made something up for that. Here goes:

IIF(isnull([Field A]),iif( isnull([Field B]),"Enter This Text","A null B not
null"),"Enter That Text")
 
J

John Spencer

IIF([FieldA] is Null and [FieldB] is Null,"Both Null"
, IIF([FieldA] is not null,"Field A has a Value",
, IIF([FieldB] is not null,"Field B has a Value",Null)))

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top