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!

Query using controls on form as criterias

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
I've created a form to be used as criterias for running a query. The form has 4 text controls and 2 yes/no controls. The query when run will look at the values within the controls on the form to determine the criterias.<br>
The controls on the form are not required.<br>
<br>
My question is: If one of the control on the form has no value, how can I make the query ignore that control (i.e. criteria).<br>

 
Look at &quot;Isnull&quot; and &quot;IIF&quot;<br>

 
If the field is truly blank (not defaulting to a zero or something), the query should treat it as though there is no criterion for that field.<br>
<br>
You might also try LIKE. Try this for the criteria:<br>
<br>
LIKE &quot;*&quot; and forms![formname]![textbox] and &quot;*&quot; <br>
<br>
This also has the effect of allowing the user to specify a part of the criterion they're looking for, so it might not be applicable in all cases.
 
You could use:<br>
WHERE (whatever = [Forms]![WhateverForm]![WhateverControl] or IsNull([Forms]![WhateverForm]![WhateverControl]))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top