Share via


MS Query and IF statements

Question

Tuesday, October 9, 2012 3:03 PM

Hi all

I hope you can help me with this maybe simple question.

I need to add a column to at MS Query where I want to use an if statement, like:
IF(Country='Danmark';DK;Other)
But is that at all possible in a Query. I get the message SYNTAX error no mather what I do.

Regards

All replies (3)

Tuesday, October 9, 2012 3:08 PM

Try

IIf([Country]='Denmark';'DK';'Other')

i.e. use IIf instead of If, and enclose all text values in (single) quotes.

If that still doesn't work, try

IIf([Country]='Denmark','DK','Other')

i.e. commas instead of semicolons.

Regards, Hans Vogelaar


Tuesday, July 4, 2017 2:22 PM

I have tried this on MS query extracting data from Sage 50 accounts and returning it to Excel, but cannot currently get it to work, I just get "column not found"

Please help?


Tuesday, July 4, 2017 4:16 PM

Have you used the correct field name instead of Country?

(I don't know anything about Sage 50, sorry)

Regards, Hans Vogelaar (http://www.eileenslounge.com)