Clearing listbox selections

  • Thread starter Thread starter mscertified
  • Start date Start date
M

mscertified

Can I just set .ItemsSelected to zero or do I have to loop thru the
selections and reset the .Selected property ?

Thanks.
 
mscertified said:
Can I just set .ItemsSelected to zero or do I have to loop thru the
selections and reset the .Selected property ?


For a multi-select list box, you need the loop, like this:

Dim varI As Variant

With Me.lstMyListbox
For Each varI In .ItemsSelected
.Selected(varI) = False
Next varI
End With

or else you can -- at the cost of rerunning the rowsource query -- reset the
list box's rowsource:

With Me.lstMyListbox
.RowSource = .RowSource
End With

I would use the former, unless I also need to requery the list box.
 
Back
Top