remove button to remove item from listbox

Posted on 2011-05-06
Last Modified: 2012-05-11
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
Question by:davetough
    LVL 74

    Accepted Solution

    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


    Author Closing Comment

    LVL 74

    Expert Comment

    by:Jeffrey Coachman

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now