I am trying to remove the selected items in a listbox that allows multiple selection. The code below loops the correct number of time (i.e. if I have 4 items selected, it loops 4 times), however, it prints out the first item in the list, not the items that are selected. When I actually try to remove the items, it only removes the first item in the list, not the first selected items.
Going batty over this one. Any help is appreciated.
Private Sub cmdRemove_Click()
Dim frm As Form, ctl As Control
Dim varItm As Variant
Set frm = Me
Set ctl = Me.lstProductsAssigned
For Each varItm In ctl.ItemsSelected
Debug.Print ctl.ItemData(vatItm)
Next varItm
End Sub
The only thing worse than being alone, is wishing you were.
Going batty over this one. Any help is appreciated.
Private Sub cmdRemove_Click()
Dim frm As Form, ctl As Control
Dim varItm As Variant
Set frm = Me
Set ctl = Me.lstProductsAssigned
For Each varItm In ctl.ItemsSelected
Debug.Print ctl.ItemData(vatItm)
Next varItm
End Sub
The only thing worse than being alone, is wishing you were.