Results 1 to 5 of 5
  1. #1
    guilpter is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2013
    Posts
    3

    Deleting existing recod

    Hi, guys I;m new with the MS access and i need some help I hope you can help me so, here's the problem i have this adding VBA code
    Private Sub btnAdd_Click()
    Dim dbFilmi As DAO.Database
    Dim rstInfoTBL As DAO.Recordset

    Set dbFilmi = CurrentDb
    Set rstInfoTBL = dbFilmi.OpenRecordset("InfoTBL")

    rstInfoTBL.AddNew
    rstInfoTBL("ID").Value = Me.txtID
    rstInfoTBL("Name").Value = Me.txtName


    rstInfoTBL("DOB").Value = Me.txtDateFrom
    rstInfoTBL.Update
    rstInfoTBL.Close


    End Sub
    how do i make a delte button :X

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The keyboard Delete will delete record. Do you want to disable it and create your own delete button?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    guilpter is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2013
    Posts
    3
    Yes I want to create my own delete button and to delete the existing record

  4. #4
    guilpter is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2013
    Posts
    3
    dim dbs as dao.database
    dim rst as dao.recordset

    set dbs = currentdb

    set rst = dbs.openrecordset("tablename")

    Then to delete records, find the relevant row in the recordset and...

    rst.delete

    This one should do the trick but i don't know how "to find the relevant row in the recordset"
    ..

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If you want to delete the current selected record on form:

    DoCmd.RunCommand acCmdDeleteRecord

    If you want to delete record(s) not on the form:

    CurrentDb.Execute "DELETE FROM tablename WHERE ID=" & Me.ID

    The example used ID field as criteria but could be whatever you need to identify the record.

    However, none of this prevents user from using the keyboard Delete.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 11
    Last Post: 05-23-2012, 08:42 AM
  2. Deleting rows
    By ads8525 in forum Access
    Replies: 13
    Last Post: 02-10-2012, 08:52 AM
  3. Replies: 0
    Last Post: 02-25-2011, 09:40 AM
  4. Replies: 11
    Last Post: 12-14-2010, 01:25 PM
  5. Deleting Duplicates
    By TundraMonkey in forum Queries
    Replies: 4
    Last Post: 09-08-2009, 07:13 AM

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