In my database I have a table with several yes/no columns.
Now, I have a unbound form with some unbound checkboxes and a listbox bound to a special query just for it.
I want to use the checkboxes on the form to filter the listbox and display items in the list that have matching values.
For example,
- If I check box1 on the form, any item that contains field1 in the listbox should show.
- If I check box2 and box3 on the form, any item that contains field2 AND field3 should display in the listbox. If an item does not have both field3 AND field3, their entries should not show in the list because the boxes are not checked.
Each control on the form uses an on-click event procedure to cause the list to requery.
Right now, this doesn't work right for me. My listbox only displays items when ALL the values match the checkbox. So, if I check box1 and box2, I only get the results from items that have only field1 and field2. If the item also has field3, it doesn't display - and this is my problem.
This is what my query looks like so far:
SELECT MyQuery.title, field1, MyQuery.field2, MyQuery.field3
FROM MyQuery
WHERE (
(
(MyQuery.field1) like [Forms]![Ability Finder]![box1]
)AND(
(MyQuery.field2) like [Forms]![Ability Finder]![box2]
)AND(
(MyQuery.field2) like [Forms]![Ability Finder]![box3]
)
);
Maybe I'm going about this all the wrong way. Also, I have about 20 checkboxes for which I need to do this.
SELECT MyQuery.cat, MyQuery.nickname, MyQuery.title, MyQuery.level, MyQuery.field1, MyQuery.field2, MyQuery.field3
FROM MyQuery
WHERE (
((MyQuery.field1)=[Forms]![Ability Finder]![box1] Or [Forms]![Ability Finder]![box1] Is Null)
AND ((MyQuery.field2)=[Forms]![Ability Finder]![box2] Or [Forms]![Ability Finder]![box2] Is Null)
AND ((MyQuery.field3)=[Forms]![Ability Finder]![box3] Or [Forms]![Ability Finder]![box3] Is Null)
);