Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004
    Posts
    364

    Unanswered: Delete Records via Listbox??

    I have a list box which displays the Id's and Age of people in my database. I use it to select which ID i want to view on a form to show the records full details of about 30 fields.

    I want to be able to select an ID in the list box, then click a button to delete its entire record from the database.

    Any ideas?

    Cheers

  2. #2
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146
    Create a new command button with OnClick to set to the following code:

    Private Sub cmd1_Click()
    DoCmd.SetWarnings False
    DoCmd.RunSQL "delete * from tblAges where AgeID = " & Me!List1
    DoCmd.SetWarnings True
    Me!List1.Requery
    End Sub
    This example assumes that your command button is named cmd1, your table is named Ages, your field is named AgeID, and your list box is named List1. Keep in mind also that this example disables warnings.

    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •