IIf query invalid syntax

tezread

Registered User.
Local time
Today, 21:53
Joined
Jan 26, 2010
Messages
330
I have a conditional query:

IIf(([202 Method of Admission] = "1. Called GP who saw patient then called emergency services" Or [202 Method of Admission] = "2. Called GP who called emergency service then saw patient” Or [202 Method of Admission] = “3. Called 999"),"Called 999", IIf([202 Method of Admission] = "4. Called NHS Direct" Or [202 Method of Admission] = "5. Made own way to hospital (did not call anyone)” Or [202 Method of Admission] =“6. Called local helpline“ Or [202 Method of Admission] = "7. Called GP - told to make own way to hospital" Or [202 Method of Admission] = "9. Transferred for PCI/Surgery“, “A&E”, “Other”))

But this is not working - due to highlighted invalid syntax?

Many thanks for support in advance
 
I think Access wants you to use proper normal " instead of the “ you have scattered around

Beyond that, I will leave out the speech about naming convention as well as the speech about normalization...
Part of this is just screaming bad design
 
IIF in a query is usually very slow and difficult to debug. In your case all the text strings do not help the readability.

I hope this is a save guess: using the first character of the string instead of the complete string defines the string uniquely? If so, rewrite your statement as follows:
Code:
IIf[COLOR="Red"]([/COLOR](Left$([202 Method of Admission],1) = "1" Or Left$([202 Method of Admission],1) = "2” Or Left$([202 Method of Admission],1) = “3"[COLOR="red"])[/COLOR],"Called 999", 
IIf(Left$([202 Method of Admission],1" = "4" Or Left$([202 Method of Admission],1) = "5” Or Left$([202 Method of Admission],1) =“6“ Or Left$([202 Method of Admission],1) = "7" Or Left$([202 Method of Admission],1) = "9", “A&E”, “Other”))
The second IIF is executed in the Else part of the first IIF.

Remove the red braces.

HTH:D
 

Users who are viewing this thread

Back
Top Bottom