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?
|
|
0
|
|
|
|
Reply
|
Utf
|
10/26/2007 8:07:00 PM |
|
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]))
"hongloumeng" wrote:
> 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?
|
|
0
|
|
|
|
Reply
|
Utf
|
10/26/2007 8:24:01 PM
|
|
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]))
--
Bob Larson
Access World Forums Super Moderator
____________________________________
If my post was helpful to you, please rate the post.
"hongloumeng" wrote:
> 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?
|
|
0
|
|
|
|
Reply
|
Utf
|
10/26/2007 8:26:02 PM
|
|
Thank you both.
"hongloumeng" wrote:
> 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?
|
|
0
|
|
|
|
Reply
|
Utf
|
10/26/2007 8:32:05 PM
|
|
|
3 Replies
310 Views
(page loaded in 0.094 seconds)
|