Solved

Access ListBox select multiple items

Posted on 2010-08-24
4
1,043 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 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:Murray Brown
ID: 33525992
Thanks very much
0
 
LVL 30

Expert Comment

by:hnasr
ID: 33526315
Welcome!
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

696 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