What Is Wrong With This "IIF" Statement?

P

PeteCresswell

Seems tb retuning an empty string or Null, no matter what:

=IIf([LadderRoleID]=0,"(none)",IIf([LadderRoleID]=1,"Ladder
Parent",IIf([LadderRoleID]=2,"Ladder Child of SecurityID " &
[SecurityID_LadderParent],"ERROR")))

I put a field right next to it, w/.ControlSource=LadderRoleID and I
see values of 0, 1, and 2 there.
So I'm pretty sure that LadderRoleID isn't Null.

??
 
P

PeteCresswell

Maybe I should add that the "IIF" statement in question has been
pasted into the field's .ControlSource...
 
M

Maarkr

1. ? try it without the '& [securityid_ladderparent] portion.
2. is the [ladderroleid] a text field?... = "1"
 
S

Sylvain Lafontaine

Add a field with ControlSource = [SecurityID_LadderParent] as well;
otherwise, it's possible that this second field won't be retrieved and the
whole expression will evaluate to null or #Error because, when using an IIF
statement, all the subexpressions are evaluated before performing the logic.

Also, on some systems (like mine), you must use the semi-comma ";" instead
of the comma "," to separate each element of an IIF statement.
 

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