473,387 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Append before deleting the record

I know it is best said to archive records when you press delete button. I need help with this.

I have a list box where filtered data is showed. The user highlights the record and clicks on delete button to delete the record. This at the minute completely takes off that record. How do i back-up this data so that on clicking delete button it will remove the record from list box but append to other table called tblBackup?

I have tried making append query which i tried to put the code in vba, but with no success.

code currently on delete button is as follows:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdDelete_Click()
  2. Dim strSQL As String
  3.  
  4. If MsgBox("Are you sure you want to delete selected record?", vbYesNo, "Confirm") = vbYes Then
  5.  
  6. strSQL = "DELETE FROM EmployeeTbl WHERE ID = " & Me.ResultList
  7. CurrentDb.Execute strSQL
  8.  
  9. End If
  10.  
  11. End Sub 
Sep 27 '06 #1
1 1825
PEB
1,418 Expert 1GB
Hi,

So before the delete SQL you need an Insert Into SQL

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdDelete_Click()
  2. Dim strSQL As String
  3.  
  4. If MsgBox("Are you sure you want to delete selected record?", vbYesNo, "Confirm") = vbYes Then
  5.  
  6. strSQL = "INSERT INTO Mylog(COl01,Col02,COl03) SELECT COl01,Col02,COl03 FROM EmployeeTbl WHERE ID = " & Me.ResultList
  7. CurrentDb.Execute strSQL
  8.  
  9. strSQL = "DELETE FROM EmployeeTbl WHERE ID = " & Me.ResultList
  10. CurrentDb.Execute strSQL
  11.  
  12. End If
  13.  
  14. End Sub 
  15.  
Hope that helps!

:)

Best regards!
Sep 27 '06 #2

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

Similar topics

2
by: Paul Wagstaff | last post by:
Hi there I have 2 tables: tblAccuracy & tblClearance Users add new records to tblAccuracy using frmRegister. Under specific conditions I need to append the current record from frmRegister into...
1
by: Mark | last post by:
This question refers to a main form with a continuous form subform. After an error occurs after entering several records in the subform, how can I delete all the data in the main form and all the...
2
by: Ray Holtz | last post by:
I have a form that shows a single record based on a query criteria. When I click a button it is set to use an append query to copy that record to a separate table, then deletes the record from the...
46
by: DP | last post by:
hi, i've got a form, with a subform in it. i've got a delete button in the subform. the code i;ve got is; Private Sub cmdDeleteRecord_Click() msg = "Are you sure you want to delete this...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
6
by: jcf378 | last post by:
hello-- i am having trouble figuring out how to export individual records from an Access 2002 Form into a pre-existing Excel spreadsheet, such that the exported record is merely appended to the...
10
by: pythonnoob | last post by:
Hello everyone. New to python as well as this forum, but i must say ive learned a but already reading through some posts. Seems to be a pretty helpful community here. Before i post a question...
3
by: hikosj | last post by:
Hi all, I have a problem with a query in access that I cant seem to figure out. I have a form named frmRecruitment with a subform named sfrmParticipant. At the moment I am using an append query to...
1
by: Kyosuke18 | last post by:
Hi everyone, I have a problem in deleting a data that is connected on the database.. I tried this code but it shows me an error: Run-time error '-2147217900(80040e14)': Syntax error in string in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.