Access -The "IIf" Statement

  • Thread starter Thread starter Roger Bell
  • Start date Start date
R

Roger Bell

I am attempting to use the IIf statement as follows on a
form:

=IIf([Age]>6,"Primary",IIf[Age]>7,"Class 2"))

It will work for the first IIf, does not accept for the
second IIf. Can someone plesae help?
 
-----Original Message-----

"Roger Bell" <[email protected]> schreef in bericht
I am attempting to use the IIf statement as follows on a
form:

=IIf([Age]>6,"Primary",IIf[Age]>7,"Class 2"))

It will work for the first IIf, does not accept for the
second IIf. Can someone plesae help?

There is no true part in the second iif.


John

http://www.john-peskens.nl


.
Thank you John for your response. You mentioned that
there is no true part in the second iif in my statement.



Does that mean I cannot get it to work.

I have a data base which has a date of birth field and an
age field which automatically calculates when the DOB is
entered. I also have a field called School Level. I
want a statement in this to enter the respective School
level depending on age, as outlined in my statement
below. The IIf statement would expand up to Class 12 and
the idea is that the School level will increase as we
enter a new year.



This is something like I want it to look like & do:



=IIf([Age]>4 and < 5,K1, iif[age]>5 and < 6,Preprimary,iif
[age]>6 and < 7, 1)))



Any help would be greatly appreciated.



Regards

Roger Bell
 
I think what John means, is that you are misssing the "If true" and
"Else If" elements of the second IIf. That your second IIf is
incomplete.

=IIf([Age]>6,"Primary",IIf([Age]>7,***InsertIfTrueValueHere***,***InsertElseIfValueHere),"Class
2"))

Please notice the added parenthesis for the second if and the tags,
that's what you were missing.

Isaack

-----Original Message-----

"Roger Bell" <[email protected]> schreef in bericht
I am attempting to use the IIf statement as follows on a
form:

=IIf([Age]>6,"Primary",IIf[Age]>7,"Class 2"))

It will work for the first IIf, does not accept for the
second IIf. Can someone plesae help?

There is no true part in the second iif.
 
Roger said:
I am attempting to use the IIf statement as follows on a
form:

=IIf([Age]>6,"Primary",IIf[Age]>7,"Class 2"))

It will work for the first IIf, does not accept for the
second IIf. Can someone plesae help?

I would have to get back to some old files and check but there seems to
be two problems.

First I don't think you ")"s are balanced.

However I believe the first condition ">6" will be satisfied and the
processing will stop before it looks for the second condition for any
possible ">7"
 
I am attempting to use the IIf statement as follows on a
form:

=IIf([Age]>6,"Primary",IIf[Age]>7,"Class 2"))

It will work for the first IIf, does not accept for the
second IIf. Can someone plesae help?
Your statement wants to print "Primary" if the age is 7 (i.e. greater
than 6), and "Class 2" if the age is 8 (i.e. greater than 7).
But both 7 and 8 are greater than 6, so the first part of the
expression is always true.

I don't think you mean what your expression says.
Don't you really mean
If([Age] =6 , "Primary", or If Age is 7 or greater,"Class2" ?

=IIf([Age]=6,"Primary",IIf[Age] >=7,"Class 2","Age is Less than 6"))
 
Try:


=IIf([Age]>7,"Class2",(IIf([Age]>6,"Primary"),"")

This will use "Class2" for Age >7, "Primary" for Age >6 (but <=7), and
nothing for
all other cases (Age <=6).
 
In the case that your value reads say, 8, it is true for both instances and access doesn't know what to do. You need your second IIF statement to not be true for the first


----- Roger Bell wrote: ----

I am attempting to use the IIf statement as follows on a
form

=IIf([Age]>6,"Primary",IIf[Age]>7,"Class 2")

It will work for the first IIf, does not accept for the
second IIf. Can someone plesae help
 
Back
Top