de-select items in a listbox

P

PeterM

Is there a way using VBA to unselect (deselect) all entries in a multi-select
or single-select listbox?

Thanks in advance for your help!
 
D

Dirk Goldgar

PeterM said:
Is there a way using VBA to unselect (deselect) all entries in a
multi-select or single-select listbox?

Thanks in advance for your help!

A single-select list box is easy: just set its value to Null.

For a multiselect list box:

'----- start of code -----
Function ClearListBoxSelections(lst As Access.ListBox)

Dim intI As Integer

With lst
For intI = (.ItemsSelected.Count - 1) To 0 Step -1
.Selected(.ItemsSelected(intI)) = False
Next intI
End With

End Function

'----- end of code -----
 
Top