multiselect listbox to filter subform combobox

D

deb

I have a form called f4Project. It has a subform called f4ProjUnitSub.
f4ProjUnitsub is a continuous form.

How can I have a ListBox called lstSiteID on the main form f4Project, and
select multiple options and have the subform combobox called cboUnitID
display the data filtered from the listbox.

i.e. On the main form I select Site A and Site B from the listbox. The
subform's combo box now shows only the Units related to Site A and Site B.

Thank you in advance.
 
T

Tom Wickerath

Hi Deb,

I've never done anything like this, but here's a guess as to how you might
proceed:

1.) In the AfterUpdate event procedure of the listbox, use VBA code to
iterate the .ItemsSelected property of the listbox. An example of iterating
an unbound listbox is shown in a sample file available for a presentation I
gave last month to the Seattle Access User's Group. See the download for
February 12, 2008, here:

http://www.seattleaccess.org/downloads.htm

2.) Use the items selected to build an appropriate WHERE clause for the
RowSource of your combo box. This would be similar to building an appropriate
WHERE clause for a subform, as shown in my example. You might want to start
the combo box off with a RowSource that includes all items, so that if a user
does not make a selection in the listbox on the main form, they won't have an
empty rowsource for the combo box.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 

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