ListBox Refresh Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello to all,

I have a ListBox that's setup to save selected items to a table when a
button is clicked. It works fine, but the items stay selected after the data
has been saved.

Using VB, how do I force the ListBox back into an unselected state? I want
the selected items to become unselected after the button is clicked.

Button Name = btnAddItems
ListBox Name = lstDisplayItems

-Simon
 
Private Sub cmdAddItems_Click()
Dim varRowNumber As Variant
With Me.lstDisplayItems
For Each varRowNumber In .ItemsSelected
Me.lstDisplayItems.Selected(varRowNumber) = False
Next varRowNumber
End With
End Sub
 
Use the following code to clear the seleted items:

Dim varItem As Variant
Dim ctl As Control

Set ctl = Me.[YourListboxName]
For Each varItem In ctl.ItemsSelected
ctl.Selected(varItem) = False
Next varItem
 
R. Hicks, Bill Edwards,

Thanks to both of you. Both versions of your code work just fine.
I Luv This Forum :-)

-Simon
 
Hi Simon:

Could you please provide me the codes that populate your table when items
are selected in the listbox. I need it badly, thanks.
 
Back
Top