IIF statement

C

connieharper

I am using access 2000 and have created a report. It
contains a calculated field called [points]. I can't get
the right syntax on this IIf statement. If I just use the
one IIf statement it works but I need to incorporate a
couple "OR"s in there.

In english, if the grade = "A" it will display the value
in the [points] field but if the grade = "B" it will
display the value in the [points 2] field and if the
grade = "C" it will display the value in the [points 3]
field. Can you help. I think my "Or" is in the wrong
place.


=IIf([pre_course_grade]="A",[Points],0) OR IIf
([pre_course_grade]="B",[Points 2],0) OR IIf
([pre_course_grade]="C",[Points 3],0)
 
L

Les

Try this:

=IIf([pre_course_grade]="A",[Points], IIf
([pre_course_grade]="B",[Points 2], IIf
([pre_course_grade]="C",[Points 3],"other-condition")))

Just threw other-condition in because what do you do if
grade isn't A, B, or C?
 
P

PeterH

Perhaps the Choose() function would be
better. "A", "B", "C", etc. can translate into numeric
values which choose() handles quite well.
 
C

connieharper

This worked great! Thanks.

-----Original Message-----
Try this:

=IIf([pre_course_grade]="A",[Points], IIf
([pre_course_grade]="B",[Points 2], IIf
([pre_course_grade]="C",[Points 3],"other-condition")))

Just threw other-condition in because what do you do if
grade isn't A, B, or C?
-----Original Message-----
I am using access 2000 and have created a report. It
contains a calculated field called [points]. I can't get
the right syntax on this IIf statement. If I just use the
one IIf statement it works but I need to incorporate a
couple "OR"s in there.

In english, if the grade = "A" it will display the value
in the [points] field but if the grade = "B" it will
display the value in the [points 2] field and if the
grade = "C" it will display the value in the [points 3]
field. Can you help. I think my "Or" is in the wrong
place.


=IIf([pre_course_grade]="A",[Points],0) OR IIf
([pre_course_grade]="B",[Points 2],0) OR IIf
([pre_course_grade]="C",[Points 3],0)
.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top