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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Box - Select All

Status
Not open for further replies.

JazzEars

Technical User
Apr 13, 2004
3
US
I am trying to create a list box on a form with an option of "Select All". Can anyone help me with the code for this?
 
JazzEars
There may be other ways, but here is code that I found.

Your list box will be a simple Multi-Select list box. Put a check box on your form. Checking it will select all records, unchecking it will deselect all.

Dim i As Integer

If Yourchkbox Then
For i = 0 To Yourlistbox.ListCount - 1
Yourlistbox.Selected(i) = True
Next i
Else
For i = 0 To Yourlistbox.ListCount - 1
Yourlistbox.Selected(i) = False
Next i
End If

Change Yourchkbox to the name of your check box. Change Yourlistbox to the name of your list box.

Put the code on the Click event for Yourchkbox.

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top