Multiple IIf statements

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having trouble placing multiple Include If (IIf) statements in a query.
There are a number of organisms with full names in our database, I want to
pull them but have them all displayed under the most generic of their names.
The following statement works fine up until the second IIf. When I add that
segment, I get a message saying I there is a syntax error or I have not
included enough brackets.

Org_1 Change: IIf([Org_1] Like "ESBL*","ESBL",[Org_1]),IIf[Org_1] Like
"CR*","Carbapenem",[Org_1])

The mistake is probably obvious, but could someone help me see what I'm not
seeing?
 
You need to nest your IIF statements within each other

IIf («expr», «truepart», IIf («expr», «truepart», «falsepart») )

IIf([Org_1] Like "ESBL*","ESBL",IIf[Org_1] Like "CR*","Carbapenem",[Org_1]))
 
You have one too many [Org_1] and parentheses in wrong places. Here you go:

Org_1 Change: IIf([Org_1] Like "ESBL*","ESBL",IIf([Org_1] Like
"CR*","Carbapenem",[Org_1]))
 

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

Multiple iif challenge 2
Query Criteria IIf statement 4
IIf statement 1
IIf statement in update query 3
IIF statements 2
Aggregate Function Error 0
iif statement 2
IIF Statement 5

Back
Top