Select All in a listbox

  • Thread starter Thread starter sweeneysmsm
  • Start date Start date
S

sweeneysmsm

Is there a way to select all of the records in a listbox instead of having to
select each one individually?

I am using the listbox to send stored e-mail addresses so that a report can
be sent out. In some instances I might want to select individuals, but in
others I might want to select all. I have tried the usual Shift key while
establishing a block but that does nothing.

Thanks for whatever insight you can provide.

Mary
 
Change the Multiselect property to Extended.

You then can select the first item, scroll down to the end of the list, hold
down the Shift key, and click on the last item.
 
Mary:

If you want to do it by means of a 'Select All' button on the form the
code for its Click event procedure would be like this:

Dim n As Integer
Dim ctrl As Control

Set ctrl = Me.YourListBoxName

For n = 0 To ctrl.ListCount - 1
ctrl.Selected(n) = True
Next n

Similarly, for a 'Clear Selections' button:

Dim n As Integer
Dim ctrl As Control

Set ctrl = Me.YourListBoxName

For n = 0 To ctrl.ListCount - 1
ctrl.Selected(n) = False
Next n

Ken Sheridan
Stafford, England
 
Thank you, Ken. I think I will just go with the extended multi-select but I
am grateful to have the code you sent.

Mary
 
Back
Top