how to delete selected item from a multiselect listbox

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

Guest

Hi,

I have a multiselect listbox2(style is simple) which has two columns i.e.
category and product name. it receives its values from another listbox1.
I wish to delete the selecteditem(s) from the listbox1. the code which i
have written deletes only the first record, kindly guide me how to delete the
list of selected items

cheers
bye
 
Hi:

You need to loop through the ItemsSelected collection of the ListBox. See
this from Help --

The next example uses the same list box control, but prints the values of
each column for each selected row in the list box, instead of only the
values in the bound column.

Sub AllSelectedData()
Dim frm As Form, ctl As Control
Dim varItm As Variant, intI As Integer

Set frm = Forms!Contacts
Set ctl = frm!Names
For Each varItm In ctl.ItemsSelected
For intI = 0 To ctl.ColumnCount - 1
Debug.Print ctl.Column(intI, varItm)
Next intI
Debug.Print
Next varItm
End Sub
Regards,Naresh NichaniMicrosoft Access MVP
 
Back
Top