By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,483 Members | 1,464 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,483 IT Pros & Developers. It's quick & easy.

Appending Deleted Records to a Separate Table

P: 8
I want to have any records that are deleted in my tblMain automatically appended to a separate "DeletedRecords" table as soon as they are deleted. Does anyone know of a good way to do this? The user has to click on a "DeleteRecord" button on the frmMain in order to delete a record from the table.
Oct 15 '07 #1
Share this Question
Share on Google+
3 Replies


ADezii
Expert 5K+
P: 8,597
I want to have any records that are deleted in my tblMain automatically appended to a separate "DeletedRecords" table as soon as they are deleted. Does anyone know of a good way to do this? The user has to click on a "DeleteRecord" button on the frmMain in order to delete a record from the table.
Place similar code in your Form's DELETE Event. If you need further assistance, just let me know.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Delete(Cancel As Integer)
  2. Dim MyDB As DAO.Database, MyRS As DAO.Recordset
  3.  
  4. Set MyDB = CurrentDb()
  5. Set MyRS = MyDB.OpenRecordset("tblDeletedRecords", dbOpenDynaset)
  6.  
  7. With MyRS
  8.   .AddNew
  9.     ![FirstName] = Me![txtFirstName]
  10.     ![LastName] = Me![txtLastName]
  11.     ![Address] = Me![txtAddress]
  12.   .Update
  13. End With
  14.  
  15. MyRS.Close
  16. Set MyRS = Nothing
  17. End Sub
Oct 15 '07 #2

P: 8
Thanks! This works really well.
Oct 15 '07 #3

ADezii
Expert 5K+
P: 8,597
Thanks! This works really well.
Glad it worked for you.
Oct 15 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.