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

Multiselect Criteria in query design window?

Status
Not open for further replies.

VBUser77

MIS
Jan 19, 2005
95
0
0
US
I have a list box whose multiselect prpoerty is set to "Extended". I like my query to filter data based upon the selection(s) I make in my list box. But it doesn't work. I am using this as my criteria:

Product Field

Criteria: Forms![MainForm]![lbx_Product]

I also tried to use this criteria:

Forms![MainForm]![lbx_Product].ItemsSelected

But both criteria didn't bring back anything.

However, when I change the multiselect prpopery of my list box to "None", the criteria starts working.

How can I fix it so that my query filters data based upon mutilpe selections that I make in my list box.

Thanks a lot in advance.

Jay

 
you're looking for listbox.itemsselected(n)

--------------------
Procrastinate Now!
 
How can i define "n" in the query design window. "n" is the index number of the ItemsSelected collection but if i select multipe items how it's gonna work.

Thanks
 
A filter is simply a where clause without the word Where. The function in this FAQ faq181-5497 will create and return the Where clause for you (without the word Where). It works for single and multi-select listboxes, combo boxes, date ranges, other ranges, text boxes, option groups, and check boxes. Obviously it's overkill for what you need. However, you'll be able to use it on future databases you create. You only have to do 3 things to make it work:

1. Create a new module and copy the functions from the FAQ and paste them in your new module.
2. Set the tag property of your list box as specified in the FAQ.
3. Filter the form, something like this:
Me.Filter = BuildWhere(Me)
Me.FilterOn = True

By the way, don't worry about trying to understand the code (you can if you want), just use it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top