Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete selected item out of list box

Status
Not open for further replies.

daveonion

Programmer
Aug 21, 2002
359
GB
Hi, i have a list box and when i double click a record in it i want it to be deleted, the code i currently have only deletes the earliest record so any help on what code to use would be appreciated.
 
Use the removeitem method of the listbox control. You have to specify the index. In your dblclick event handler, you'd put:

ListBox1.RemoveItem ListBox1.ListIndex

Rob
[flowerface]
 
hi Rob, thanks for your suggestion, the only problem is the way its set up is the list box has a table as its row source and not a value list, so i need it to actually delete the selected record out of the table, any more ideas would be appreciated thanks
Dave
 
OK, try this:

Range(ListBox1.RowSource).Range("A1").Offset(ListBox1.ListIndex).Delete shift:=xlShiftUp

Rob
[flowerface]
 
hi Rob, my vb doesn't read range. what library is it in?
thanks
 
alright rob my application was access, thanks for all your help, somebody else hs helped me out in a different forum and now its all fine, once again thanks
Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top