IIf Statement Help

  • Thread starter Thread starter DS
  • Start date Start date
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
 
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
 
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
 
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
 
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
 
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
 

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

Similar Threads


Back
Top