Reset Listbox

X

XMan

Is there a better to unselect selected items in listbox instead of calling
requery()?
I assume requery() will go do DB functions and may take more time as I have
many listboxes.
TIA.
 
C

Connie

Here's what I've used. I'm sure there's a better way, but at least it
works. lstName is the name of the listbox control.

Dim intDeSelectAll As Integer
Dim i As Variant

intDeSelectAll = lstName.ListCount

For i = 0 To intDeSelectAll
lstName.Selected(i) = False
Next

I believe you could use the Me.Refresh to remove the selections, however, if
I recall, if the user has selected all items then it would still display as
if all were still selected.

Connie
 
X

XMan

It's working.
Thanks for the tip!


Connie said:
Here's what I've used. I'm sure there's a better way, but at least it
works. lstName is the name of the listbox control.

Dim intDeSelectAll As Integer
Dim i As Variant

intDeSelectAll = lstName.ListCount

For i = 0 To intDeSelectAll
lstName.Selected(i) = False
Next

I believe you could use the Me.Refresh to remove the selections, however, if
I recall, if the user has selected all items then it would still display as
if all were still selected.

Connie
 

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