Parameters

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

Guest

I have created a form to enter parameters into a query which returns
information on people. On the Form I have a Combo for Gender as well as two
Unbound Text Boxes to select the beginning Age and end Age. This is all
working fine if the user selects the ages they want and selects either
'Female' or 'Male' using the combo. I would also like to give the user the
option to select both ie male and female so that they can view everyone
between the specified ages - how do I do that then?
 
The best way I know is to put the following in as a field in your query:
IIf(IsNull([Forms]![Form1]![Combo0]),1,0)
and then add the criteria of 1, and then in the first line of or add the
identical criteria for age and 0 for the new field

Here is the SQL
SELECT test.sex, test.age, test.name,
IIf(IsNull([Forms]![Form1]![Combo0]),1,0) AS Expr1
FROM test
WHERE (((test.sex)=[Forms]![Form1]![Combo0]) AND ((test.age) Between
[Forms]![Form1]![Text3] And [Forms]![Form1]![Text5]) AND
((IIf(IsNull([Forms]![Form1]![Combo0]),1,0))=0)) OR (((test.age) Between
[Forms]![Form1]![Text3] And [Forms]![Form1]![Text5]) AND
((IIf(IsNull([Forms]![Form1]![Combo0]),1,0))=1))
 

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

Back
Top