My version of access does not like IIF.

Mee

New member
Local time
Today, 11:15
Joined
Feb 17, 2021
Messages
10
Hello Everyone.
I am trying to insert the following field into a query: Units:IIF([RTCAKitNum]=665,"mg/mL", "ng/mL")
RTCAKitNum is a number field, the commas & quotes are correct but all I get is syntax error message. If I change it to
Test:IIF(1+1=2,"yes", "no")
I also get a syntax error. I can't find any test entry that will accept the syntax.
What am I missing?
Thanks for the help. Mee
 
Hello Everyone.
I am trying to insert the following field into a query: Units:IIF([RTCAKitNum]=665,"mg/mL", "ng/mL")
RTCAKitNum is a number field, the commas & quotes are correct but all I get is syntax error message. If I change it to
Test:IIF(1+1=2,"yes", "no")
I also get a syntax error. I can't find any test entry that will accept the syntax.
What am I missing?
Thanks for the help. Mee
Mee. I tested your Test:IIF(1+1=2,"yes", "no") on my versions of access which is 2016 and the syntax produces the correct result Yes .
What version are you using, maybe some of the forum members have the version you are using and can assist you further .
Have you tried creating a new query just using your Test syntax and no other fields apart from the ID ?

Ypma
 
Check to see if you have a broken reference. Do other string functions work (left, right, instr, etc)?
 
We are using Office 365 enterprise
1613565609315.png

-Mee
 
what is the mso language you are using?
 
Check to see if you have a broken reference. Do other string functions work (left, right, instr, etc)?
You're right, Left doesn't work either. Without extensive testing, I assume the others are broken as well.
 
I think @arnelgp was wondering what your international locale settings were.

In some locations the , gets replaced by a semicolon
IIf(1+1=2 ; "True" ; "False")

Edit - but I see @MajP has ht the nail on the head. References missing or a corrupt file.
 
Perhaps "Units" is already defined as a field in the table.

When It's right IIF will only have the first letter capitalised - Iif

Maybe it's worth doing a compact and repair on your database because this should be working correctly.
 
if left() isn't working, check your references. Open a code module, and do Tools/References. See if any are missing. Otherwise, maybe you need them in a different order.
 
Ok, you have exceeded my understanding already. Is English a stupid answer?
sorry, because Other language uses semicolon instead of comma as separator.
 
@gemma-the-husky The iif will be displayed as IIf when the syntax is correct.
A sort of camel case for Immedite If
Interesting idea but not it. I tested IIF, Iif, IiF, if, IF, If.
One curious thing; when I switched from IIF to IF, I got the same syntax error. It didn't switch to "bad command" or some error like that.

I also tried swapping out the commas for ; . or |. Didn't like those either, although with the pipe, it did finally change the error message.
 
And all references are good?
 
These are kind of classic symptoms of the VBA library not loading due to a broken or missing reference, but if that is not the case you may have to do a reinstall. Can you post a screen shot of your references?
 
These are kind of classic symptoms of the VBA library not loading due to a broken or missing reference, but if that is not the case you may have to do a reinstall. Can you post a screen shot of your references?
It's a company computer so I'll have to get our IT to do it.

1613570511712.png

The RTCAKitNum field is coming from another query. The point of the query I'm trying to build is to join the query data with data from another table.
 
This has nothing to do with your query.

Open the VBA editor, press Ctrl + G to open the immediate window. Type the following;

? IIF(1+1=2,"yes", "no")

And hit return - you will almost certainly get an error.
1613570943372.png


To check your references in the same VBA editor click tools and select references;
1613570912596.png


What do you see? This is what I see O365 Win 10
1613571005821.png
 
I did as you suggested. ?IIF(1+1=... returned the correct answer, no errors here.
In the VBA editor, when I click tools, References is greyed out; I can't select it. Is this the source of all the problems and how do I fix it?
 
I take that back.
I see this
1613571692982.png

What does this mean?
 

Users who are viewing this thread

Back
Top Bottom