listbox deselects during removeitem

abbers_01

Registered User.
Local time
Today, 07:22
Joined
Aug 31, 2007
Messages
45
I'm using a button a remove entries in a listbox using this code,
_________________________________________________________________
Private Sub removeCompanyBtn_Click()
For i = 0 To Me.customerQueryList.ListCount - 1
If (Me.customerQueryList.Selected(i)) Then
Me.customerQueryList.RemoveItem i
End If
Next
End Sub
_________________________________________________________________
But what is happening is when I select a entry and press the remove button, it removes the first entry it finds and then the list box deselects all the entries I have selected. It still goes through the loop but because they were all deselected it won't remove them.

Anyone know why it would be deselecting after the first one is removed?

would it be helpful to add my listbox settings?
 
Try going through the list in reverse order. ie: start at the end and move to the beginning.
 

Users who are viewing this thread

Back
Top Bottom