471,354 Members | 1,487 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Passing multiple selections from a column to a combobox or list box

3
Hello, I have a question about making multiple selection queries in Access. I am running windows XP and Access 2003. Up until this point I had a form where a user would make single selections from a combo box and the following combo box would filter based on the initial selection. I now would like to give the opportunity to make multiple selections and the following combo box would filter based on that. How do I go about declaring this variable and passing the selections onto the next column?

Thank you,
Mar 27 '07 #1
4 2641
ADezii
8,826 Expert 8TB
Hello, I have a question about making multiple selection queries in Access. I am running windows XP and Access 2003. Up until this point I had a form where a user would make single selections from a combo box and the following combo box would filter based on the initial selection. I now would like to give the opportunity to make multiple selections and the following combo box would filter based on that. How do I go about declaring this variable and passing the selections onto the next column?

Thank you,
__1. You cannot make multiple selections from a Combo Box - you must use a List Box.
__2. I'll assume that it is a single column List Box, and that you want to make multiple selections from choices made within it.
__3. For demo purposes, we'll name the List Box lstTest.
__4. Set the Multi Select Property of the List Box to Extended. This will enable you to use both CTRL and SHIFT in your selections.
__5. To retrieve all Selected Items from lstTest and build your Criteria String:
Expand|Select|Wrap|Line Numbers
  1. Dim ctl As Control, varItm As Variant
  2.  
  3. Set ctl = Me![lstTest]
  4.  
  5. For Each varItm In ctl.ItemsSelected
  6.   Debug.Print ctl.ItemData(varItm)
  7. Next varItm
Mar 27 '07 #2
tbayse
3
Thank you for you reply and the code. I realized that combo boxes would no pass a multiple selection and have switched to a list box. In the code after I make a selection do I update the After Update event procedure with your code? Currently I have the code ...

Private Sub List81_AfterUpdate()
Me.Combo83 = Null
Me.Combo83.Requery
Me.Combo83 = Me.Combo83.ItemData(0)
End Sub

This code was used on combo boxes to pass single selections to the next box. Should I use a union of your code and this to perform the same? Thank you for your help.
Mar 28 '07 #3
ADezii
8,826 Expert 8TB
Thank you for you reply and the code. I realized that combo boxes would no pass a multiple selection and have switched to a list box. In the code after I make a selection do I update the After Update event procedure with your code? Currently I have the code ...

Private Sub List81_AfterUpdate()
Me.Combo83 = Null
Me.Combo83.Requery
Me.Combo83 = Me.Combo83.ItemData(0)
End Sub

This code was used on combo boxes to pass single selections to the next box. Should I use a union of your code and this to perform the same? Thank you for your help.
Expand|Select|Wrap|Line Numbers
  1. Dim ctl As Control, varItm As Variant
  2.  
  3. Set ctl = Me![lstTest]
  4.  
  5. Me![Combo83].RowSourceType = "Value List"   'necessary
  6. Me![Combo83].RowSource = vbNullString       'Clear out
  7.  
  8. For Each varItm In ctl.ItemsSelected
  9.    Me![Combo83].AddItem ctl.ItemData(varItm)
  10. Next varItm
Mar 28 '07 #4
tbayse
3
Thank you again for you quick reply. Is there a way to post my access database so you can look at what I'm trying to do? Currently the code you have supplied have changed my row source for the combo box to something other then the query box was supposed to find. The original list box that I am trying to make multiple selections from had a field in it that was related to the following table. With a selection, or multiple selections the combo box that follows was to match that field and display items. For example the original list box was MODEL and the following combo box was ACTIVITY. This was a 1 to many relationship. With selection of a MODEL a MODEL ID was known, this was then matched through the query to ACTIVITY that had that model. I hope this makes sense. If not how can I make it clearer?

Thank you again, you have been a tremendous help so far.

Tim
Mar 29 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Therese A. Sorna | last post: by
2 posts views Thread by Craig B. | last post: by
5 posts views Thread by Keith G | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.