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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Form value to filter Query

Status
Not open for further replies.

pryest

Programmer
Dec 26, 2006
24
US
I am using a combo box on a form to supply a value for a query to filter by. The problem I have is that I would like the query to be able to show everything if I don't select a value on the form. Below I have listed the WHERE statement from my query. Do you have any suggestions on how I can correct it?

WHERE (((qry_TW_Filter1_by_date.[Projected Posession Date])<#2/1/2008#) AND ((qry_TW_Filter1_by_date.[R-Real Estate Dir])=[forms]![MainForm]![Combo10]));
 
Here is what I used. WHERE (((CGSTbl.ProdID) Like "*" & [Forms]![CGS Class Select frm]![CGS Class Select Combo]))

In this statement the "Like "*" returns everything if the control on the form is left blank. Substitute your own Form/Field reference for the remainder of the statement.
 
How are ya pryest . . .

Perhaps this:
Code:
[blue]WHERE (((qry_TW_Filter1_by_date.[Projected Posession Date]<#2/1/2008#) AND (qry_TW_Filter1_by_date.[R-Real Estate Dir]=[forms]![MainForm]![Combo10])) [purple][b]OR ([forms]![MainForm]![Combo10] Is Null)[/b][/purple]);[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks guys. It is working great now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top