Getting query to filter based on values in a List Box (multiselect)

  • Thread starter Thread starter Neil
  • Start date Start date
N

Neil

Hello,

Been trying to figure this one out for a while now.

I have a query which lists all available items for a product. These are
displayed in a ListBox on an unbound form. What I was hoping to do was to be
able to filter the items the user has selected and add these to a new table.
Adding to a new table is the easy bit but filtering the records is not. The
listbox's bound column is the primary key value used in the query. The
english for my query that i want is:

return all records in my query where the RecordID is in the listbox's
selected items.

I know it will be something like SELECT MyFields FROM MyQuery WHERE RecordID
IN ListboxSelectedItems

I dont know how to write this in SQL using the correct syntax and which
property or properties of the listbox i need to use to get the selected
items only.

Can any body help?

TIA,

Neil.
 
I'm not sure off the top of my head (I don't use a lot of multi-select ListBoxes) ..

however ..

whenever I have trouble with SQL syntax, I build the query in normal QueryDesign View and then copy the syntax into my VBA pane

See if that works for you


----- Neil wrote: ----

Hello

Been trying to figure this one out for a while now

I have a query which lists all available items for a product. These ar
displayed in a ListBox on an unbound form. What I was hoping to do was to b
able to filter the items the user has selected and add these to a new table
Adding to a new table is the easy bit but filtering the records is not. Th
listbox's bound column is the primary key value used in the query. Th
english for my query that i want is

return all records in my query where the RecordID is in the listbox'
selected items

I know it will be something like SELECT MyFields FROM MyQuery WHERE RecordI
IN ListboxSelectedItem

I dont know how to write this in SQL using the correct syntax and whic
property or properties of the listbox i need to use to get the selecte
items only

Can any body help

TIA

Neil
 
Thanks howard,

I cant get my head round on what to put into the criteria field here either
to return the selected items in my listbox. I dont know how to get Acces to
look in each of the listbox's selected rows. This is where i am having the
problem.

Neil.

Howard Brody said:
I'm not sure off the top of my head (I don't use a lot of multi-select ListBoxes) ...

however ...

whenever I have trouble with SQL syntax, I build the query in normal
QueryDesign View and then copy the syntax into my VBA pane.
 
Back
Top