My version of access does not like IIF. (1 Viewer)

Mee

New member
Local time
Yesterday, 22:03
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
 

ypma

Registered User.
Local time
Today, 03:03
Joined
Apr 13, 2012
Messages
643
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
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 22:03
Joined
May 21, 2018
Messages
8,525
Check to see if you have a broken reference. Do other string functions work (left, right, instr, etc)?
 

Mee

New member
Local time
Yesterday, 22:03
Joined
Feb 17, 2021
Messages
10
We are using Office 365 enterprise
1613565609315.png

-Mee
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:03
Joined
May 7, 2009
Messages
19,228
what is the mso language you are using?
 

Mee

New member
Local time
Yesterday, 22:03
Joined
Feb 17, 2021
Messages
10
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.
 

Minty

AWF VIP
Local time
Today, 03:03
Joined
Jul 26, 2013
Messages
10,366
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.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 03:03
Joined
Sep 12, 2006
Messages
15,634
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.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 03:03
Joined
Sep 12, 2006
Messages
15,634
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.
 

Minty

AWF VIP
Local time
Today, 03:03
Joined
Jul 26, 2013
Messages
10,366
@gemma-the-husky The iif will be displayed as IIf when the syntax is correct.
A sort of camel case for Immedite If
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:03
Joined
May 7, 2009
Messages
19,228
Ok, you have exceeded my understanding already. Is English a stupid answer?
sorry, because Other language uses semicolon instead of comma as separator.
 

Mee

New member
Local time
Yesterday, 22:03
Joined
Feb 17, 2021
Messages
10
@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.
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 22:03
Joined
May 21, 2018
Messages
8,525
And all references are good?
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 22:03
Joined
May 21, 2018
Messages
8,525
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?
 

Mee

New member
Local time
Yesterday, 22:03
Joined
Feb 17, 2021
Messages
10
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.
 

Minty

AWF VIP
Local time
Today, 03:03
Joined
Jul 26, 2013
Messages
10,366
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
 

Mee

New member
Local time
Yesterday, 22:03
Joined
Feb 17, 2021
Messages
10
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?
 

Mee

New member
Local time
Yesterday, 22:03
Joined
Feb 17, 2021
Messages
10
I take that back.
I see this
1613571692982.png

What does this mean?
 

Users who are viewing this thread

Top Bottom