IIf Statement Help

D

DS

I need to write an IIf statement with 3 criteria and need a little help
if you could please.

If ItemType= 1, [ItemName]&[EMemo]
If ItemType=2, " "&[ItemName]&[EMemo]
If ItemType=3, " "&[ItemName] &[EMemo]

The statement would be an expression in a Query.
Any help appreciated.
Thanks
DS
 
E

e.mel

try
IIf (ItemType=1, [ItemName]&[EMemo], IIf(ItemType=2,"
"&[ItemName]&[EMemo], " "&[ItemName] &[EMemo]) )

thats assuming if ItemType is not 1 or 2 then it must be three
.. . . I love IIf <3
 
T

Tom Lake

e.mel said:
try
IIf (ItemType=1, [ItemName]&[EMemo], IIf(ItemType=2,"
"&[ItemName]&[EMemo], " "&[ItemName] &[EMemo]) )

thats assuming if ItemType is not 1 or 2 then it must be three
. . . I love IIf <3

How's that going to work? The second IIf is done if the first IIf is true
which means the second IIf must be false.

Tom Lake
 
J

jmonty

Nest the IIF statements. Replace the "DefaultValueHere" with the string you
want to assign it if it is not 1,2,or3. (Maybe NULL or a null string "")

IIF (ItemType=1, [ItemName]&[EMemo], IIF(ItemType=2, "
"&[ItemName]&[EMemo], IIF(ItemType=3, " "&[ItemName] &[EMemo],
"DefaultValueHere")))


jmonty
 
D

DS

Tom said:
try
IIf (ItemType=1, [ItemName]&[EMemo], IIf(ItemType=2,"
"&[ItemName]&[EMemo], " "&[ItemName] &[EMemo]) )

thats assuming if ItemType is not 1 or 2 then it must be three
. . . I love IIf <3


How's that going to work? The second IIf is done if the first IIf is true
which means the second IIf must be false.

Tom Lake
It works for 1 and 3 but 2 comes up blank!
Thanks
DS
 
D

DS

DS said:
Tom said:
try
IIf (ItemType=1, [ItemName]&[EMemo], IIf(ItemType=2,"
"&[ItemName]&[EMemo], " "&[ItemName] &[EMemo]) )

thats assuming if ItemType is not 1 or 2 then it must be three
. . . I love IIf <3



How's that going to work? The second IIf is done if the first IIf is
true which means the second IIf must be false.

Tom Lake
It works for 1 and 3 but 2 comes up blank!
Thanks
DS
I stand corrected, I had a slight typo...it works!!!!!!
Thnak You E.Mel
DS
 
Top