IIF statement

  • Thread starter Thread starter connieharper
  • Start date Start date
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)
 
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?
 
Perhaps the Choose() function would be
better. "A", "B", "C", etc. can translate into numeric
values which choose() handles quite well.
 
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)
.
.
 
Back
Top