Filtering data using a list box as criteria in my SQL statement

J

JB63

When I use a list box as criteria in the sql statement to filter data I would
like to return all data if the box is left blank, any Ideas?
 
J

JB63

I use multiple list boxes in a form to display data in a subform on the form,
I sort this data using criteria in the subform's SQL ,"ex. EquipmentID
(criteria) [Forms]![LogSearch]![EquipmentID] and ShiftID (criteria)
[Forms]![LogSearch]![ShiftID]" I would like the form to display all of the
logs when the list box is left blank.
Thanks for the reply i am new to this forum.
 
K

Klatuu

Can't help without the SQL you referenced in your original post. Sorry, but
your most recent post only added to the confusion

JB63 said:
I use multiple list boxes in a form to display data in a subform on the
form,
I sort this data using criteria in the subform's SQL ,"ex. EquipmentID
(criteria) [Forms]![LogSearch]![EquipmentID] and ShiftID (criteria)
[Forms]![LogSearch]![ShiftID]" I would like the form to display all of the
logs when the list box is left blank.
Thanks for the reply i am new to this forum.

Klatuu said:
Post the SQL so we can see what it looks like now, please.
 
J

John W. Vinson

When I use a list box as criteria in the sql statement to filter data I would
like to return all data if the box is left blank, any Ideas?

= [Forms]![YourForm]![YourListtbox] OR [Forms]![YourForm]![YourListbox] IS
NULL

This will only work for a single-select listbox, though; if you are using a
multiselect listbox you'll need some code.
 
J

JB63

John W. Vinson said:
When I use a list box as criteria in the sql statement to filter data I would
like to return all data if the box is left blank, any Ideas?

= [Forms]![YourForm]![YourListtbox] OR [Forms]![YourForm]![YourListbox] IS
NULL

This will only work for a single-select listbox, though; if you are using a
multiselect listbox you'll need some code.
 
Top