IIF Statement NOT working with number logic tests

Anonymous
2021-04-14T12:57:58+00:00

I have a simple IIF statement;

IIF ([Marks]>50,"Pass","Fail")

But Access returns a syntax error. I have tried the IIF statement with Dates it works. I can even add marks onto existing mark, meaning all functions works but only when the logic test has to deal with numbers then I have a problem. Please help!!!

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} vote

14 answers

Sort by: Most helpful
  1. Anonymous
    2021-04-14T14:03:06+00:00

    SELECT scores.House, scores.Mark, IIf([FrDate]>=Date(),'90','10') AS Wee, [Mark]+90 AS Grade

    FROM scores;

    Only this code pops up because it won't accept the 'problematic code'. I think there has to be a setting or something to do with testing numbers....

    0 comments No comments
  2. Anonymous
    2021-04-14T14:14:49+00:00

    Try changing it in SQL View, saving and then running it to see if per chance that works.

    SELECT scores.House, scores.Mark, IIf(scores.FrDate >= Date(),'90','10') AS Wee, IIF(scores.Mark > 50, "Pass", "Fail") AS Grade

    FROM scores;

    What Access build number are you running?

    Have you tried running an Office Repair?

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2021-04-14T14:32:59+00:00

    It runs perfectly! BUT...

    The minute I go back into the Query code to change say even the 'pass mark' from 50 to say 52, then when it has to execute the new code, it goes back to the same issue;

    Either way, this is very helpful as I can then code in using SQL. The execution problem seems linked to my app as the problem is replicated with all my machines (under the same license). Looks like other Access users can type in the code and run it. Looks like the problem could be confined to my Office 'ecosystem'.

    Thank you so much!

    0 comments No comments
  4. Anonymous
    2021-04-14T14:37:53+00:00

    I'd try performing an Office Repair.

    I'd still like to know your Access build number (File -> Account).

    0 comments No comments
  5. Duane Hookom 26,575 Reputation points Volunteer Moderator
    2021-04-14T14:38:48+00:00

    I would open your VBA window (press Ctrl+G) and check the references (Tools->References).

    See if any references are noted as MISSING.

    Then compile your code by clicking Debug->Compile to see if any errors are reported.

    0 comments No comments