|
|
|
Access -The "IIf" Statement |
| message from Roger Bell on 16 May 2004 |
=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?
|
| Michael J. Strickland replied to Roger Bell on 17 May 2004 |
=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).
|
| =?Utf-8?B?U0NITllERVM=?= replied to Roger Bell on 17 May 2004 |
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.
|
| Joseph Meehan replied to Roger Bell on 17 May 2004 |
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"
|
| anonymous replied to John on 16 May 2004 |
schreef in bericht
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
|
| Isaack Rasmussen replied to anonymous on 17 May 2004 |
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
<anonymous@discussions.microsoft.com> wrote in message news:<de8301c43bdb$92613fe0$a601280a@phx.gbl>...
|
| fredg replied to Roger Bell on 17 May 2004 |
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"))
|
|