add/edit/delete item on a listbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • laidz08
    New Member
    • Dec 2012
    • 3

    #1

    add/edit/delete item on a listbox

    hi!

    I have a list box with three columns and then three command buttons, add/edit/delete,. I've worked out for the code, but it's not working, maybe because my row source type is set to a table/query instead of value list. Is there any way that i can do those buttons functional for a row source type set to a table/query? Please help me T_T
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    I have never tried doing this, but here is what I would look into. In the On_Click event you will need to open the recordsource for your list box. This is done with the following code:
    Code:
    Dim db as DAO.Database
    Dim rstListBox as DAO.Recordset
    Set rstListBox = db.OpenRecordset([I]The row source of your listbox[/I])
    You would then use the .AddNew, .Edit, or .Delete methods depending on which button you click. The .Edit and .Delete methods would have to use the selection in the listbox as the criteria for a rstListBox.Find First method so that you could find the appropriate record and then either edit it or delete it.

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      Respectfully, Bytes is not a code nor homework service. Your post is subject to being removed because asking for someone to provide completed code or a completed project is against site policy - even if someone has already offered a solution. Please consult the FAQ and specific forum sticky threads for further information.

      You need to provide your code/work and the exact title/error-number/error-text for all error messages received.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        If your row source type is Table/Query then all you can do to effect the list shown (short of changing the data in the table of course) is to change the filtering of the data. IE. Change the query, or change to a query if using a table.

        Comment

        Working...