Access Iif in syntax error

I keep getting an error on:

Food: IIF ([Event] In (“Orange”,“Apple Slice”,“Pineapple Slice”), “Fruit Group”)
exp vgAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
except for the space after IIF and the " (double quotes seems odd)

copy and paste this

Food: IIF([Event] In ("Orange","Apple Slice","Pineapple Slice"), "Fruit Group")
exp vgAuthor Commented:
Should I use single quotes instead of double?
Rey Obrero (Capricorn1)Commented:
and you need to add the false statement value of the IIF() function
the syntax is

IIf(expr, truepart, falsepart)


Food: IIF([Event] In ("Orange","Apple Slice","Pineapple Slice"), "Fruit Group", "False part value goes here")
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

exp vgAuthor Commented:
I am still getting an error message.
Rey Obrero (Capricorn1)Commented:
<Should I use single quotes instead of double? > it should be double quotes

the double quotes you used in your original post is the one used by MS Word and access will not understand it.
Rey Obrero (Capricorn1)Commented:
upload a copy of your db.
Dale FyeOwner, Developing Solutions LLCCommented:
What is the error message and #?

 Seems strange that a field called [Event] would contain the name of a fruit or vegetable.  Are you sure that is the correct field?
Rey Obrero (Capricorn1)Commented:
- incorrect field name is irrelevant for the syntax error, as long as the field name is in the table

even if you made a mistake of selecting the field from the table, it will not throw any error, it will just return blank result



.
hieloCommented:
Try adding Eval() around the first expression:
 IIF( Eval([Event] In (“Orange”,“Apple Slice”,“Pineapple Slice”)), “Fruit Group”, "Veggie?")
https://support.office.com/en-au/article/IIf-Function-32436ecf-c629-48a3-9900-647539c764e3
PatHartmanCommented:
I'm not sure where you are going with this example.  It seems to have been dumbed down to make it easy to explain.  But, in the real world, you will almost certainly have more than one group and so a single IIf() isn't really going to solve the problem.

The best solution to give you flexibility and maintainability is to create a lookup table.  Use a left join to the lookup table and pick up the group name if a record is found.
exp vgAuthor Commented:
The double quotes may be the issue. Let me retry.
Rey Obrero (Capricorn1)Commented:
<The double quotes may be the issue. Let me retry.>

do the typing in QBE window.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
exp vgAuthor Commented:
Thank you everyone - I have had not had the time today to revisit this - will do so as soon as I can. Appreciative of everyone's assistance.
exp vgAuthor Commented:
The quotes do seem to be the solution - when I type in Expression Builder I am able to save and do not get an error.

Is there another application I can use in substitute of the QBE since this is a small screen and the expression I will type will be lengthy.

Thank you.
Rey Obrero (Capricorn1)Commented:
you can use Notepad or Notepad++
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.