Share via

Error using iif function

Anonymous
2024-03-16T21:59:45+00:00

When using the iif function I get an error that says 'you omitted an operand or operator, you entered an invalid character or comma, or you entered text without surrounding it in quotation marks'. I get this even when I try:

iif((1+1=2),"yes","no")

I've been working on this for a few hours, trying different things. I called MS support and apparently this is the only forum to get help. Having that function for the work I'm doing is critical. Any suggestions please?

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

24 answers

Sort by: Most helpful
  1. Anonymous
    2024-03-18T10:09:05+00:00

    Maths equation error.

    IIF((1+1)=2,"Yes","No")
    

    You did not evaluate the value. (1+1=2), you need to change it to (1+1) = 2.

    Was this answer helpful?

    0 comments No comments
  2. George Hepworth 22,855 Reputation points Volunteer Moderator
    2024-03-17T17:26:12+00:00

    As I mentioned earlier, the simple version DID return the correct result in my IDE, so I don't think it's a bug, per se.

    Did you try the variation I posted above? Again, it works correctly on this computer, so it seems to be something other than a bug in Access.

    If you want to try to explore further, you could provide a sample accdb with just enough data to test. If so, you could post it on a publicly accessible place like a OneDrive folder and provide a link.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2024-03-17T15:56:52+00:00

    I'm actually encouraged that you got the same error - it's not just me!! Thank you for continuing to look into this.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2024-03-17T15:54:41+00:00

    I've tried three different list separators - comma, semicolon, and pipe. None works.

    Was this answer helpful?

    0 comments No comments