Multilist box

  • Thread starter Thread starter Michael S via AccessMonster.com
  • Start date Start date
M

Michael S via AccessMonster.com

I have a form with a list box that I want to set the "Multi Select " to
extend. List Box name is "selection" with one column and 7 choices. Anyone
know the code I need to add to make access loop through to select all items
picked?
 
The help file has a very good example for this. Lookup "Listbox Object" in
help while in the VB editor then the ItemsSelected property.

There are two options, depending on whether you want the value from the
Bound Column or the value from a specified column.

1) Value from the Bound Column:
Sub BoundData()
Dim frm As Form, ctl As Control
Dim varItm As Variant

Set frm = Forms!Contacts
Set ctl = frm!Names
For Each varItm In ctl.ItemsSelected
Debug.Print ctl.ItemData(varItm)
Next varItm
End Sub

2) Value from a specified column(s):
Sub AllSelectedData()
Dim frm As Form, ctl As Control
Dim varItm As Variant, intI As Integer

Set frm = Forms!Contacts
Set ctl = frm!Names
For Each varItm In ctl.ItemsSelected
For intI = 0 To ctl.ColumnCount - 1
Debug.Print ctl.Column(intI, varItm)
Next intI
Debug.Print
Next varItm
End Sub

These are the examples from the help file. If there is only one column, then
it will also be the Bound Column and you can use the first example.
 
Using what is selected in the list box, I will be filtering a report
 
Back
Top