Select all in Listbox

D

Daniel

Hello,

What code would I use in the Form Open Event to by default have all the
items in a list box selected?

Thanks,

Daniel
 
A

Allen Browne

Private Sub Form_Load()
Dim lng As Long

With Me.[NameOfYourListBoxHere]
For lng = 0 To .ListCount - 1
.Selected(lng) = True
Next
End With
End Sub
 
D

Daniel

Thank you so very much!

Allen Browne said:
Private Sub Form_Load()
Dim lng As Long

With Me.[NameOfYourListBoxHere]
For lng = 0 To .ListCount - 1
.Selected(lng) = True
Next
End With
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Daniel said:
Hello,

What code would I use in the Form Open Event to by default have all the
items in a list box selected?

Thanks,

Daniel
 

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

Top