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

Form field as criteria in query 1

Status
Not open for further replies.

krets

Technical User
Dec 29, 2006
214
US
On a form I am using I have a drop-down field that is used to control the filtering of a sub form. There is also a button on the main form that exports the sub form's source query with:

Code:
DoCmd.OpenQuery "qryJoinXtb2", acViewNormal
DoCmd.OutputTo acOutputQuery, "qryJoinXtb2", acFormatXLS, "AIT Totals.xls", True

If the user has set a filter criteria I would like the query to reflect that. I tried doing that using a WHERE statement:

WHERE xtbRphAITNew.CellNum Like Forms!frmAITTotals.CellNum;

My problem with that is when there is no value in the form filter I get a blank query. What is the best way to go about this?
 
You may try this:
WHERE xtbRphAITNew.CellNum Like Forms!frmAITTotals.CellNum OR Forms!frmAITTotals.CellNum Is Null

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top