Results 1 to 4 of 4
  1. #1
    Fran is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2010
    Posts
    4

    Displaying records as a list in the form and then deleting records from that list

    Hi folks

    I know everyone says this but I'm a bit of a newb with Access and the small amount of VBA I understand is self taught.

    I have a data entry form that just has one field to enter a loginID. I want it to list on the same form all loginIDs that have been entered so that it's easy to see at a glance which have already been added. I've managed to get it do do this using a list box, is this the best/only way? It needs to be able to update as soon as a new record is saved.

    So then, my next problem is how can I delete from that list, so that it comes off the list box and also from the table it's coming from (tblusers)?

    I want a delete button that when pressed, deletes which ever loginID is selected in the list box. Any ideas please?



    Many thanks
    Fran

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,523
    Try

    CurrentDb.Execute "DELETE * FROM tblUsers WHERE loginID= " & Me.ListboxName
    Me.ListboxName.Requery

    That makes a couple of assumptions, but see if it works.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Fran is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2010
    Posts
    4
    Thanks for the effort, but I got an error message "Runtime error 3464, Data type mismatch in criteria expression"

    Any thoughts?

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,523
    If loginID is text, it would need to be:

    CurrentDb.Execute "DELETE * FROM tblUsers WHERE loginID= '" & Me.ListboxName & "'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Restart auto number after deleting records
    By P5C768 in forum Database Design
    Replies: 1
    Last Post: 09-11-2009, 02:07 PM
  2. Filttering List Box's Records
    By Alec in forum Forms
    Replies: 0
    Last Post: 08-12-2009, 02:10 PM
  3. Displaying records from a form
    By ceb39 in forum Access
    Replies: 5
    Last Post: 04-03-2009, 12:36 PM
  4. Problem Deleting Records with ADO
    By bdicasa in forum Programming
    Replies: 0
    Last Post: 08-21-2008, 09:27 AM
  5. Lookup or list field: how Do I not show all records
    By scott munkirs in forum Forms
    Replies: 4
    Last Post: 04-13-2006, 12:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums