Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple criteria in a query? 1

Status
Not open for further replies.

robbie59

Technical User
May 9, 2001
36
US
I have a unbound form for query criteria and I would like to
have the user be able to select for example a month for the query but I would also like for them to be able to select between a range of months I have tried using the or criteria box with the between function but it still shows all records. Any ideas? If knowledge were power I would be a AAA battery!
 
Here is one possible solution.

Select * From table1
Where month1 between [forms]![myform].[text1]
And IIf([forms]![myform].[text2] Is Null, [forms]![myform].[text1], [forms]![myform].[text2])


The IIf function evaluates the contents of text2. If the box is empty, it will substitute the value of text1. Otherwise, it will assume text2 is a month and use it. The query assumes that text1 will always contain a valid month.
Terry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top