MS Access - Listbox

A

Allen Browne

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
 

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

Similar Threads

Submit form 0
populate listbox form database table 0
Listbox search question 4
Accessing a form object 2
Cancel listbox selection 2
Open form 0
User Input to Generate ListBox Range 0
populating listboxes 2

Top