We help IT Professionals succeed at work.
Get Started

Multiple criteria with InStr function?

DanielAttard asked
Last Modified: 2006-11-17
Please have a look at the multiple criteria that I am testing for to return the word "Green".  Currently I am checking for 16 different words, but I need to check for about 40 possible words.  Is there a better way for me to do this exercise?  Should I move everything to a function and then call the function from the query?

PinColor: IIf(IsNull([Type]),"Blank",IIf(InStr([Type],"Single family detached")=1 Or InStr([Type],"home")=1,"Yellow",IIf(InStr([Type],"land")=1 Or InStr([Type],"lots")=1 Or InStr([Type],"site")=1,"Brown",IIf(InStr([Type],"Indus")=1 Or InStr([Type],"Warehousing")=1 Or InStr([Type],"gravel")=1,"Red",IIf(InStr([Type],"Retail")=1 Or InStr([Type],"Office Building")=1 Or InStr([Type],"Commercial")=1 Or InStr([Type],"shopping centre")=1 Or InStr([Type],"office")=1 Or InStr([Type],"auto")=1 Or InStr([Type],"motel")=1 Or InStr([Type],"restaurant")=1 Or InStr([Type],"hotel")=1 Or InStr([Type],"bank")=1 Or InStr([Type],"medical")=1 Or InStr([Type],"dental")=1 Or InStr([Type],"store")=1 Or InStr([Type],"dealership")=1 Or InStr([Type],"marina")=1 Or InStr([Type],"clubs")=1,"Green",IIf(InStr([Type],"Multi-Res")=1 Or InStr([Type],"Rental Apartments")=1 Or InStr([Type],"condo apartments")=1,"Blue","Other"))))))

Thanks for the help.
Watch Question
This problem has been solved!
Unlock 2 Answers and 13 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE