Using a OR() like function in an IIF statement

  • Thread starter kkulakow via AccessMonster.com
  • Start date
K

kkulakow via AccessMonster.com

Hello, I am trying to create an IIF statement to test if the first character
in a field is a 1,2,8 or 9.
Something like the following:

IIf(Left([possible_SO_match],1)="1 or 2 or 8 or 9",[Possible_SO_Match],"No
Match")

Is there a way to create it without going to a 4 level nested IIF statement?
Thanks,
Kerry
 
R

Rick Brandt

kkulakow said:
Hello, I am trying to create an IIF statement to test if the first
character in a field is a 1,2,8 or 9.
Something like the following:

IIf(Left([possible_SO_match],1)="1 or 2 or 8 or
9",[Possible_SO_Match],"No Match")

Is there a way to create it without going to a 4 level nested IIF
statement? Thanks,
Kerry

Two ways come to mind. The long way is to use OR as you are, but you have
to repeat the field name each time...

IIf(Left([possible_SO_match],1)="1" or Left([possible_SO_match],1)="2" or
Left([possible_SO_match],1)="8" or
Left([possible_SO_match],1)="9",[Possible_SO_Match],"No Match")

The shorter version is to use an IN() clause.

IIf(Left([possible_SO_match],1) IN("1", "2", "8",
"9"),[Possible_SO_Match],"No Match")
 
K

kkulakow via AccessMonster.com

Thanks Rick, the IN clause is exactly what I was looking for!

Rick said:
Hello, I am trying to create an IIF statement to test if the first
character in a field is a 1,2,8 or 9.
[quoted text clipped - 6 lines]
statement? Thanks,
Kerry

Two ways come to mind. The long way is to use OR as you are, but you have
to repeat the field name each time...

IIf(Left([possible_SO_match],1)="1" or Left([possible_SO_match],1)="2" or
Left([possible_SO_match],1)="8" or
Left([possible_SO_match],1)="9",[Possible_SO_Match],"No Match")

The shorter version is to use an IN() clause.

IIf(Left([possible_SO_match],1) IN("1", "2", "8",
"9"),[Possible_SO_Match],"No Match")
 
M

Marshall Barton

kkulakow said:
Hello, I am trying to create an IIF statement to test if the first character
in a field is a 1,2,8 or 9.
Something like the following:

IIf(Left([possible_SO_match],1)="1 or 2 or 8 or 9",[Possible_SO_Match],"No
Match")

Is there a way to create it without going to a 4 level nested IIF statement?


Another way might be:

IIf(possible_SO_match LIKE "[1289]*",[Possible_SO_Match],"No
Match")
 
K

kkulakow via AccessMonster.com

Thanks Marshall. This also fits the bill. Now I have two choices!

Marshall said:
Hello, I am trying to create an IIF statement to test if the first character
in a field is a 1,2,8 or 9.
[quoted text clipped - 4 lines]
Is there a way to create it without going to a 4 level nested IIF statement?

Another way might be:

IIf(possible_SO_match LIKE "[1289]*",[Possible_SO_Match],"No
Match")
 

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