IIf statement in query

B

bruch04

Can anyone see what's wrong with the following expression, entered in
the first row of my query?

Expr 1: IIf([DVTPE]=1,"DVT",IIf([DVTPE]=2,"PE",""))

Unfortunately, there is a third option, "None", which has a value of
"3" on the form, so I can't do a basic if statement; it has to be
nested.

For the life of me I can't see what's wrong with the formula. I'm
getting "#Error" when I run the query.

Thanks.
 
D

Duane Hookom

Create a lookup table

1 DVT
2 PE
3 None

Include the lookup table in your query and join the DVTPE field with the
first field in your lookup table.
 
C

Chaim

Try using: CHOOSE (DVTPE, "DVT", "PE", "None")

Much cleaner and more readable.

Good Luck!
 
B

bruch04

Okay, thanks guys.

I've never used the CHOOSE function. Works so much better than nested
ifs.....! Works nicely.

Kind regards.
 
Top