Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmatically selecting all items in a list box

Status
Not open for further replies.

megmoo75

Programmer
Jun 14, 2003
40
US
Any suggestions on how I can programmatically select all items in a list box? I want the user to select an option button to "Select All" items in a list box.

Thanks in advance.
 
Hi megmoo75,

This will select all the items in a List Box called "MyListName":

Dim ctl As Control, i As Integer
Set ctl = Me!MyListName
For i = 0 To ctl.ListCount - 1
ctl.Selected(i) = True
Next i

Bill
 
Dim lst As ListBox
Set lst = Me.YourListBox
Dim i As Integer
Dim x As Integer
i = lst.ListCount

For x = 0 To i - 1
lst.Selected(x) = True
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top