Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy a record to another table before deleting the record 1

Status
Not open for further replies.

jpkeller55

Technical User
Apr 11, 2003
131
0
0
US
I have a button on a form that deletes records from a table and would like to have the deleted records copied to another table prior to deleting. I am using the following code to delete the record which works fine. Can anybody help me with code that I may add to this to perform the copy function?

Private Sub cmdDelete_Click()
'Deletes current record from ReferralDetail table
On Error GoTo Err_cmdDelete_Click

DoCmd.RunSQL "DELETE FROM [ReferralDetail] WHERE [ID] = FormID"
DoCmd.Requery

Exit_cmdDelete_Click:
Exit Sub

Err_cmdDelete_Click:
MsgBox Err.Description
Resume Exit_cmdDelete_Click
End Sub


Thanks, Jim
 
DoCmd.RunSQL "INSERT INTO [another table] SELECT * FROM [ReferralDetail] WHERE [ID] = FormID"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV the "INSERT INTO..." statement works perfectly! Is there a way to eliminate the message box that pops up stating that one record is to be appended?
 
DoCmd.SetWarnings False
DoCmd.RunSQL ...
DoCmd.SetWarnings True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

Thanks again for your posts... this was another issue I needed help on and sure enough, there you are with the answers...

BakerUSMC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top