MS Access - Listbox

  • Thread starter Thread starter Guest
  • Start date Start date
phoebe said:
What is the syntax to de-select items in the listbox. Thanks

For a normal list box, just set it to Null.
For a multiselect list box, loop through the ItemsSelected and set them to
False:

Function ClearList(lst As ListBox) As Boolean
On Error GoTo Err_ClearList
'Purpose: Unselect all items in the listbox.
'Return: True if successful
Dim varItem As Variant

If lst.MultiSelect = 0 Then
lst = Null
Else
For Each varItem In lst.ItemsSelected
lst.Selected(varItem) = False
Next
End If

ClearList = True

Exit_ClearList:
Exit Function

Err_ClearList:
MsgBox Err.Description
Resume Exit_ClearList
End Function
 
Back
Top