Calculated field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a field 'Classification' which I want automatically populated
depending on the values of 2 other fields, i.e. Classification = A if
([Field1]>=30 and [Field2]<100), Classification = B if ([Field1]>+10 and
[Field2]<30), Classification = C if ([Field1]>=0 and [Field2]<10).
What is the simplest way to implement this?
 
Try this, using nested iif

Classification = A if
=IIf([Field1]>=30 and [Field2]<100,"A", iif ([Field1]>=10 and [Field2]<30,
"B" ,iif ([Field1]>=0 and [Field2]<10,"C","D")))

If none of the conditions will match, it will return "D"
 
Just ignore the second line

Try this

=IIf([Field1]>=30 and [Field2]<100,"A", iif ([Field1]>=10 and [Field2]<30,
"B" ,iif ([Field1]>=0 and [Field2]<10,"C","D")))
 
I would suggest in addition that the code be in a query or in an unbound
text box rather than being in a control bound to a field. Another
possibility would be to have an If statement as a general procedure that
could be called from the form's Current event and the After Update event for
the controls bound to Field1 and Field2.

Ofer said:
Just ignore the second line

Try this

=IIf([Field1]>=30 and [Field2]<100,"A", iif ([Field1]>=10 and [Field2]<30,
"B" ,iif ([Field1]>=0 and [Field2]<10,"C","D")))

--
I hope that helped
Good luck


lyoung said:
I have a field 'Classification' which I want automatically populated
depending on the values of 2 other fields, i.e. Classification = A if
([Field1]>=30 and [Field2]<100), Classification = B if ([Field1]>+10 and
[Field2]<30), Classification = C if ([Field1]>=0 and [Field2]<10).
What is the simplest way to implement this?
 
Back
Top