IIf statement multiple?

G

Guest

I am trying to create a query off a subquery. The sbuquery pulls in all of
the data I need. Now to sort the data for the report.

Expr1: IIf([xqryKsOccupationalEmploymentSurvey]![Salary]<=7.5,"A")

This expression works, but I need to add more categories so that
IIf([xqryKsOccupationalEmploymentSurvey]![Salary] Between 7.51 And 9.49,"B")
IIf([xqryKsOccupationalEmploymentSurvey]![Salary] Between 9.5 And 11.99,"C")

And so on for a wage survey with a total of 12 wage brackets. Can these be
nested so that I get my results all in 1 column?

TIA!
 
M

Michel Walsh

Hi,


Probably, using a SWITCH(), but you can probably use another table to define
the ranges:


Ranges ' table name
SalaryLow, Class ' fields name
0 "A"
7.5 "B"
9.5 "C"
.... ; data



and then, use:

DMax("Class", "Ranges", "SalaryLow<=" & Salary)


as computed expression in your query. That assumes your class values, A, B,
C, ... are increasing as the lower limit of the range also increase.



Hoping it may help,
Vanderghast, Access MVP
 
G

Guest

Groovy, that worked Michel. Thanks much!

Michel Walsh said:
Hi,


Probably, using a SWITCH(), but you can probably use another table to define
the ranges:


Ranges ' table name
SalaryLow, Class ' fields name
0 "A"
7.5 "B"
9.5 "C"
.... ; data



and then, use:

DMax("Class", "Ranges", "SalaryLow<=" & Salary)


as computed expression in your query. That assumes your class values, A, B,
C, ... are increasing as the lower limit of the range also increase.



Hoping it may help,
Vanderghast, Access MVP







jjacob said:
I am trying to create a query off a subquery. The sbuquery pulls in all of
the data I need. Now to sort the data for the report.

Expr1: IIf([xqryKsOccupationalEmploymentSurvey]![Salary]<=7.5,"A")

This expression works, but I need to add more categories so that
IIf([xqryKsOccupationalEmploymentSurvey]![Salary] Between 7.51 And
9.49,"B")
IIf([xqryKsOccupationalEmploymentSurvey]![Salary] Between 9.5 And
11.99,"C")

And so on for a wage survey with a total of 12 wage brackets. Can these
be
nested so that I get my results all in 1 column?

TIA!
 

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

Similar Threads


Top