clear/remove highlight from selected items in listbox?

G

Guest

On a main menu, a user selects multiple rows in a list box. Double clicks
their mouse and a form opens. They do what they need to the record, then hit
a close form button and return to the main menu that contains the listbox. I
want to leave the data that was in the listbox and just remove the highlight
that makes them the selected items. Is there a property to do this in my
procedure?

me.lstboxneedingcleared.unknownproperty = action to clear selected items in
listbox

Thanks in advance!
 
D

Douglas J. Steele

One approach is to reset the RowSource:

Me.lstboxneedingcleared.RowSource = Me.lstboxneedingcleared.RowSource

but that can take some time if it's a big recordset.

Another approach is to set the list box to Null:

Me.lstboxneedingcleared.RowSource = Null

but if memory serves, that only works for Extended Multiselect, not for
Simple Multiselect.

You can always write a short routine that will work in all cases:

Sub ClearListbox(ListboxControl As Control)
Dim varSelected As Variant

For Each varSelected In ListboxControl.ItemsSelected
ListboxControl.Selected(varSelected) = False
Next varSelected

End Sub

You could then use:

Call ClearListbox(Me.lstboxneedingcleared)
 

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

Top