Select All in a listbox

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
 
K

Ken Snell MVP

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.
 
K

ken

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
 
S

sweeneysmsm

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
 

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