Filter data in a form using multi selection in a list box

G

Guest

I would like to filter data from a form using a multi selection (expanded)
list box control which lays in another form.

I have created therefore an unbound list box (Forms!frm_EffectTo.GeoCode)
that retreives data from a table (tbl_DepotData) using an sql statement
(multi selection is set to "Extended"). I want to select multiple items in
this box with result to filter the data in another form
(frm_DepotData_effect). I want to assign this action to a button.

thanks
 
A

Allen Browne

You will need to programmatically loop through the list box's ItemsSelected
collection, to build the string for the Filter of your form.

There's an example in this article:
Use a multi-select list box to filter a report
at:
http://allenbrowne.com/ser-50.html

The code is identical for a form. Just replace the "Docmd.OpenReport ..."
line with:
Me.Filter = strWhere
Me.FilterOn = True
 
G

Guest

Thank you Allen... it's been useful

Allen Browne said:
You will need to programmatically loop through the list box's ItemsSelected
collection, to build the string for the Filter of your form.

There's an example in this article:
Use a multi-select list box to filter a report
at:
http://allenbrowne.com/ser-50.html

The code is identical for a form. Just replace the "Docmd.OpenReport ..."
line with:
Me.Filter = strWhere
Me.FilterOn = True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top