By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,639 Members | 1,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,639 IT Pros & Developers. It's quick & easy.

Need help with nested IIF statement....

newnewbie
P: 54
Have a nested IIF statement that works but returns wrong values....Here's the syntax:

Expr3: IIf([validity]=2 Or 3,'valid',IIf([validity]=4,'invalid','unknown'))

Needed:
if validity is 2 or 3 = Valid,
if validity=4, invalid,
if validity=1, unknown

The expression above returns only VALID....

Help!
Thank you!
Lena
May 23 '07 #1
Share this Question
Share on Google+
3 Replies

Rabbit
Expert Mod 10K+
P: 12,441
Have a nested IIF statement that works but returns wrong values....Here's the syntax:

Expr3: IIf([validity]=2 Or 3,'valid',IIf([validity]=4,'invalid','unknown'))

Needed:
if validity is 2 or 3 = Valid,
if validity=4, invalid,
if validity=1, unknown

The expression above returns only VALID....

Help!
Thank you!
Lena
The problem is right here:
[validity]=2 Or 3

Any non-zero number is evaluated as true. So, broken up, this basically says:
[validity]=2
Or
3, i.e. True

So it will always evaluate to true.

What you need is:
[validity]=2 Or [validity]=3
May 23 '07 #2

theaybaras
P: 52
Rabbit is exactly right... you need the [validity]= before your 3

Expr3: IIf([validity]=2 Or [validity]=3,'valid',IIf([validity]=4,'invalid','unknown'))
May 24 '07 #3

newnewbie
P: 54
Thank You! It Worked!
May 24 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.