Multiple IIf statements

H

hongloumeng

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?
 
L

Lance

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]))
 
B

boblarson

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

Top