[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1065
  • Last Modified:

Access ListBox select multiple items

Hi

In Access I have a ListBox with items in it. How do I ensure that the user can select multiple items and
what VBA code would I use to list the selected items.
Thanks
0
Murray Brown
Asked:
Murray Brown
  • 2
1 Solution
 
hnasrCommented:
This code in a command button click event shows how to manipulate a multiselected items in a listbox.

ListBox: List1/properties/other/multiselect: Simple or Extended(using ctrl-click to select more items)

Private Sub cmdList_Click()
    Dim i As Integer
    Debug.Print List1.ItemsSelected.Count
    For i = 0 To List1.ItemsSelected.Count - 1
        Debug.Print List1.ItemsSelected(i) ' index of selected item
        Debug.Print List1.ItemData(List1.ItemsSelected(i)) ' value of item selected
    Next
End Sub
0
 
Richard DanekeCommented:
In 2007 and 2010, you can set the property for a combo box to Multi-select.  The operator will have check boxes next to each entry.   Multi-selcted items are shown in the combo box with values separated by commas.
When you set a mult-valued field to the source of a list, you get the list with check boxes and your sizing of the control determines how many you get to see.
Also, the values in the combo box are always sorted in the order of the combo box.
MultiSelect.JPG
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0
 
hnasrCommented:
Welcome!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now