Solved

Access ListBox select multiple items

Posted on 2010-08-24
4
1,032 Views
Last Modified: 2012-05-10
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
Comment
Question by:murbro
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
hnasr earned 500 total points
ID: 33515962
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
 
LVL 19

Expert Comment

by:Richard Daneke
ID: 33516292
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
 

Author Closing Comment

by:murbro
ID: 33525992
Thanks very much
0
 
LVL 30

Expert Comment

by:hnasr
ID: 33526315
Welcome!
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question