Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this query in SQL Server:

SELECT Dated, AccountID, AccountName, Rate, 
  case (when (Credit-Debit) > 0 then Credit-Debit END) as Credit,
  case (when (Credit-Debit) < 0 then Credit-Debit END) as Debit,
FROM TempTrallBalance

How can I convert it to Access syntax?

share|improve this question

The only issue here is that MS Access has no idea what a CASE expression is. Instead, you need to use IIF, e.g.:

IIF(Credit-Debit > 0, Credit-Debit, NULL) AS Credit,
IIF(Credit-Debit < 0, Credit-Debit, NULL) AS Debit,

BTW IIF is now supported in SQL Server 2012.

share|improve this answer
Access also has the Switch() function which more closely matches the CASE ... WHEN structure and can be used to avoid large numbers of nested IIf() functions. – Gord Thompson Nov 24 '14 at 12:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.