I am using IIF(criteria, true, false) in a SQL query in Access. It works when I run it as its own query.
I need to use this IIF function within a Union query - meaning, I need to have something like:
UNION (SELECT IIF(FieldName = “Field Value”, “Value1”, “Value2”)
However, whenever I start include quotes in a union query, the query no longer works. I have tried double and single quotes, I've tried escaping the quotes and I'm at a loss for what to do next.
Any suggestions, or is this by design? I have resorted to putting the SQL queries into a VBA function and then calling the VBA function from within the union query, but that is getting messy.
Thanks!