select all in a listbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I select all items in a listbox when a user clicks on a button? I have
some listboxes that have quite a few entries and I wanted to give my users an
easy way to select all items.

Thanks,
Clint Herman
 
Run this code to select all records in the list

For i = 0 To ListBoxName.ListCount - 1
ListBoxName.Selected(i) = true
Next i

To unselect just change it form true to false
 
You can put code behind a "SELECT ALL" button along the lines of:

Dim intLoop As Integer

For intLoop = 0 To Me.MyListBox.Listcount - 1
Me.MyListBox.Selected(intLoop) = True
Next intLoop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Access Cannot select items in listbox 1
Deselecting items in a listbox 2
Selecting Listbox items in code 2
Requery listbox 1
Listbox beforeupdate 2
Delete Single item from multi select listbox 3
Listbox Scroll Bar 1
Listbox problem 3

Back
Top