Problem with IIf Statement

  • Thread starter Thread starter Tony Williams
  • Start date Start date
T

Tony Williams

Could anyone tell me why this statement doesn't work?
=IIf(IsNull([txtfname]) And IsNull([txtsubjectcompany]),"Unknown",[txtfname]
& [txtsubjectcompany])

Basically I have a control that needs to say Unknown if 2 other controls are
null.
Thanks
Tony
 
What do you mean by "doesn't work"? Does it display #Error? Or #Name? Or
an incorrect value? Or what?
 
Use the query builder to create a query like!
SELECT txtfname, txtsubjectcompany, IIf(IsNull([txtfname]) And
IsNull([txtsubjectcompany]),"Unknown, "Known") AS YourOwnSuitableName FROM
TheAppropriateTableOrQuery
WHERE whatever
ORDER BY whatever
etc!
Hack it about 'til it works ok
Make this the query for the form then use YourOwnSuitableNameas the value
for the contral.

Might help!

Jim Bunton
 
I don't see anything wrong with the statement itself (I just tested it
and it works on my end), so maybe your controls/fields are zero
length strings (rather than Null). You might try;

=IIf(Nz([txtfname], "")="" And Nz([txtsubjectcompany],
"")="","Unknown",[txtfname] & [txtsubjectcompany])
 
Thanks Sean that's correct
Tony

Beetle said:
I don't see anything wrong with the statement itself (I just tested it
and it works on my end), so maybe your controls/fields are zero
length strings (rather than Null). You might try;

=IIf(Nz([txtfname], "")="" And Nz([txtsubjectcompany],
"")="","Unknown",[txtfname] & [txtsubjectcompany])

--
_________

Sean Bailey


Tony Williams said:
Could anyone tell me why this statement doesn't work?
=IIf(IsNull([txtfname]) And IsNull([txtsubjectcompany]),"Unknown",[txtfname]
& [txtsubjectcompany])

Basically I have a control that needs to say Unknown if 2 other controls are
null.
Thanks
Tony
 
Back
Top