IIF STATEMENT

  • Thread starter Thread starter gambler
  • Start date Start date
G

gambler

When i write the following IIF statement i get the error mesage WRONG #
ARGUMENTS. What am i doing wrong?
K:IIF([PL5HX4.RK]=1,2,0IIF([PL5HX4.RK]=2,1,0))
tHANKS
ED
 
It looks like you have an extra 0 in there. This seems like unusual
bracketing of the table and field name.
K:IIF([PL5HX4].[RK]=1,2,IIF([PL5HX4].[RK]=2,1,0))

You could rewrite this as the following if the possible values for RK as
1,2, or 3.
K:Choose([PL5HX4].[RK],2,1,0)
 
My table is ALL_HX4
I wrote a query PL5HX4. tHIS IS WHERE rk is located.
Then i wrote another query LU. It is in here that i put my iif statement.
Your suggestion didnt work.
If i write the IIf sattement as K:IIF([PL5HX4.RK]=1,2)iT WORKS
When i write it and include the second IIF statement it fails. Hope i
explained myself clearly. If not please let me know.
Thanks Duane
ed

Duane Hookom said:
It looks like you have an extra 0 in there. This seems like unusual
bracketing of the table and field name.
K:IIF([PL5HX4].[RK]=1,2,IIF([PL5HX4].[RK]=2,1,0))

You could rewrite this as the following if the possible values for RK as
1,2, or 3.
K:Choose([PL5HX4].[RK],2,1,0)

--
Duane Hookom
Microsoft Access MVP


gambler said:
When i write the following IIF statement i get the error mesage WRONG #
ARGUMENTS. What am i doing wrong?
K:IIF([PL5HX4.RK]=1,2,0IIF([PL5HX4.RK]=2,1,0))
tHANKS
ED
 
We are not looking over your shoulder at your computer screen. Please try
and describe your symptoms without using generic, meaningless terms like
"fails" and "didn't work". What happened when you tried Duane's suggestion?
Error message? What was it?
Incorrect results? Try and explain what was wrong with them. If you need to,
show examples of the data, followed by what the result of Duane's suggestion
was, followed by what you want the result to look like.
My table is ALL_HX4
I wrote a query PL5HX4. tHIS IS WHERE rk is located.
Then i wrote another query LU. It is in here that i put my iif
statement. Your suggestion didnt work.
If i write the IIf sattement as K:IIF([PL5HX4.RK]=1,2)iT WORKS

Impossible. The IIF() function requires 3 arguments and you've only supplied
2.
When i write it and include the second IIF statement it fails. Hope i
explained myself clearly. If not please let me know.
Thanks Duane
ed

Duane Hookom said:
It looks like you have an extra 0 in there. This seems like unusual
bracketing of the table and field name.
K:IIF([PL5HX4].[RK]=1,2,IIF([PL5HX4].[RK]=2,1,0))

You could rewrite this as the following if the possible values for
RK as 1,2, or 3.
K:Choose([PL5HX4].[RK],2,1,0)

--
Duane Hookom
Microsoft Access MVP


gambler said:
When i write the following IIF statement i get the error mesage
WRONG # ARGUMENTS. What am i doing wrong?
K:IIF([PL5HX4.RK]=1,2,0IIF([PL5HX4.RK]=2,1,0))
tHANKS
ED
 
Bob Barrows said:
Impossible. The IIF() function requires 3 arguments and you've only
supplied 2.


Quite possible, actually. While the VBA IIf() function requires all 3
arguments, the JET SQL IIf() function does not. In a query, it's the SQL
version of the function that will be used, not the VBA function of the same
name.
 
Dirk said:
Quite possible, actually. While the VBA IIf() function requires all 3
arguments, the JET SQL IIf() function does not. In a query, it's the
SQL version of the function that will be used, not the VBA function
of the same name.

Learn something new every day, I guess. I always assumed it was using the
VBA function and never realized there was a JetSQL version.

I assume it returns Null if the test expression fails and no false result is
supplied ...
 
Bob Barrows said:
Learn something new every day, I guess. I always assumed it was using the
VBA function and never realized there was a JetSQL version.

There are just a couple of VBA functions that have native JetSQL functions
with the same name (and slightly different characteristics). I believe Nz()
is another, but I'm not 100% sure.

The Jet IIf() function is different in another way: the VBA function always
evaluates both the "return-if-True" operand and the "return-if-False"
operand, while the Jet version only evaluates the argument that is going to
be returned.
I assume it returns Null if the test expression fails and no false result
is supplied ...

Quite right.
 
Back
Top