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]))
 
Back
Top