• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 316
  • Last Modified:

remove button to remove item from listbox

I have a remove button problem - to remove item from listbox- it does remove from listbox visually-
but when I add record to database- the removed item is there with other items

the database is attached- open- form comes up-  
enter service#-select name- enter 2 part numbers - try to select part number and use remove button-
you will see it looks like removes but does not.

am using:
If Me.lstPartsUsed <> -1 Then
 Me.lstPartsUsed.RemoveItem Me.lstPartsUsed.ListIndex
  MsgBox "Select an item to remove"
End If
thank you
  • 2
1 Solution
Jeffrey CoachmanMIS LiasonCommented:
A list box has a RowSource (that feeds the listbox)
If you want to *really* remove an item form a listbox, you must remove it from the Row source.

This does not necesarilly mean that you must delete the item form the table....
If the listbox is based on a query you can simply add a "Removed" Yes/No field to the table.
Then set this to yes or no depending on if you want the item seen or not.

If this case the source for yor listbox will be something like this:
SELECT fld1, fld2, Removed
FROM YourTable
WHERE Removed=False

davetoughAuthor Commented:
Jeffrey CoachmanMIS LiasonCommented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now