?
Solved

Access ListBox select multiple items

Posted on 2010-08-24
4
Medium Priority
?
1,048 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:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
hnasr earned 2000 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:Murray Brown
ID: 33525992
Thanks very much
0
 
LVL 30

Expert Comment

by:hnasr
ID: 33526315
Welcome!
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

765 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