Clear a listbox

E

Erwin Bormans

Hi all

In my Acces project I got multiple listboxes.

Is there an easy way to clear the listbox if you click a button.

I tried Me.lstBox.Clear / Clear Me.lstBox but it doesn't work.

Kind regards
Erwin
 
D

Douglas J. Steele

How you do

Dim varSelected As Variant

For Each varSelected in Me.ListboxName.ItemsSelected
Me.ListboxName.Selected(varSelected) = False
Next varSelected


Alternatively, if the Multiselect property is None (0) or Extended (2), you
can clear all selected entries strictly by setting the list box to Null. If
the Multiselect property is Simple (1) or Extended (2), you can clear all
selected entries by resetting the RowSource property:

Select Case Me.lstEmployees.MultiSelect
Case 0 ' None
Me.lstEmployees = Null
Case 1 ' Simple
Me.lstEmployees.RowSource = Me.lstEmployees.RowSource
Case 2 ' Extended
Me.lstEmployees = Null
Me.lstEmployees.RowSource = Me.lstEmployees.RowSource
End Select
 
Top