iif Function (1 Viewer)

daameta

Registered User.
Local time
Today, 02:30
Joined
May 26, 2015
Messages
25
hi all
i have two textbox in my report "Percentage" or "Grade". According to name percentage show percent and grade show grade. now i am calculating grade ( which is depend on percentage) where condition is-->
lower limit upper limit grade
0 30 E
31 40 D
41 60 C
61 80 B
81 100 A
So what is IIf statement on above condition.
can i create another table on above condition. and use them to calculate grade. if so what is method to do this.
 

sneuberg

AWF VIP
Local time
Today, 02:30
Joined
Oct 17, 2014
Messages
3,506
In the follow code replace txtPercentage with the name of the text box that has the percentage and then put it in the control source of the text box for the grade.

Code:
=IIf(txtPercentage < 31, "E", IIf(txtPercentage < 41, "D", IIf(txtPercentage < 61, "C", IIf(txtPercentage < 81, "B", "A"))))
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:30
Joined
May 7, 2009
Messages
19,249
you can create a table, ie: tblGradeMark, and put the limits and grade there.
fields:
lower (integer)
Upper(integer)
Grade(text)

on your query:

select studentID, studentName, FormatPercent(IIF([score]>0,[score]/100, 0)), tblGradeMark.Grade FROM tblStudent, tblGradeMark WHERE [score] Between [Lower] And [Upper]
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:30
Joined
May 7, 2009
Messages
19,249
just a sample field, should correspond to the numeric grade or test score (if test) in your table.

need to be replaced with correct fieldname in your table.
 

Users who are viewing this thread

Top Bottom