I am unable to remove multiple items from a listbox. Here's what I've tried in Access2002/Windows2000:
**Note** lstTo is the name of the listbox control
Dim iX As Integer
For iX = lstTo.ListCount - 1 To 0 Step -1
If lstTo.Selected(iX) Then lstTo.RemoveItem iX
Next iX
This only removes the last selected item. It seems to set all other selected items to a non-selected state after removing the last selected item in the list.
Also tried this:
Dim varI as variant
For Each varI In lstTo.ItemsSelected()
lstTo.RemoveItem lstTo.ListIndex
Next
Same result.......Only removes the first item in ItemsSelected and then jumps the loop as if no other items are selected. If I step this code without the RemoveItem line then I can loop through all items that are selected. Any assistance will be greatly appreciated.
**Note** lstTo is the name of the listbox control
Dim iX As Integer
For iX = lstTo.ListCount - 1 To 0 Step -1
If lstTo.Selected(iX) Then lstTo.RemoveItem iX
Next iX
This only removes the last selected item. It seems to set all other selected items to a non-selected state after removing the last selected item in the list.
Also tried this:
Dim varI as variant
For Each varI In lstTo.ItemsSelected()
lstTo.RemoveItem lstTo.ListIndex
Next
Same result.......Only removes the first item in ItemsSelected and then jumps the loop as if no other items are selected. If I step this code without the RemoveItem line then I can loop through all items that are selected. Any assistance will be greatly appreciated.