Calculated Field: What am I doing wrong????

Access_Help

Registered User.
Local time
Yesterday, 22:34
Joined
Feb 12, 2005
Messages
136
The calculated field converts all percentage marks perfectly fine with grades except 100 which returns to a stupid "E" . Anyone find the mistake? I've been trying all sorts and now give up.

Code:
Grade:IIf([Percentage]<20,"U",IIf([Percentage]<30,"G",IIf([Percentage]<40,"F",IIf([Percentage]<"50","E",IIf([Percentage]<60,"D",IIf([Percentage]<70,"C",IIf([Percentage]<80,"B",IIf([Percentage]<90,"A",IIf([Percentage]<100,"A+")))))))))
 
The big mistake I see is IIF statements nested 8 deep (+/- 1, you have so many I may have counted inaccurately).

After nesting 2 deep its time to build a function. You then pass your function a value and it returns what its suppose to. When you write a function you can take up as many lines as you want and don't have to jam everything into 1. I suggest you move this logic to a function, use as many lines as necessary and when it goes wrong, you will be able to better pinpoint the part of the code failing.
 

Users who are viewing this thread

Back
Top Bottom