Click Event Function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

On my form I have a delete button to delete the selected record, that works
ok but what I want ot add is to run a Append Query that will copy the record
to an Archive database prior to deleting. I have the query and archive
function working but my knowledge is limited - how can I run the query before
deleting. I was going to add it to the Click Event of the delete button but
that is already in use.

Need help - in novice terms...

Thanks - George
 
You can add it to the click event of the delete button. That would be the
best place to put it. Put it just before you do the delete. If you need
more specific info, post back with the code you are using to do the delete.
 
When I try to add this to the Click Event - the "Event Procedure" is already
there - when I open it the following code is there.

Private Sub Delete_Record_Click()
On Error GoTo Err_Delete_Record_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Delete_Record_Click:
Exit Sub

Err_Delete_Record_Click:
MsgBox Err.Description
Resume Exit_Delete_Record_Click

End Sub

How can I add to run a query called "Q-Archive-Records"

Thanks - George
 
On my form I have a delete button to delete the selected record, that works
ok but what I want ot add is to run a Append Query that will copy the record
to an Archive database prior to deleting. I have the query and archive
function working but my knowledge is limited - how can I run the query before
deleting. I was going to add it to the Click Event of the delete button but
that is already in use.

Need help - in novice terms...

Thanks - George

Create a Delete query that will delete the selected record.
Use the
forms!FormName!RecordID
criteria syntax so that just the one Record shown in the form is
deleted.
Create an Append query that will append the selected record to your
archive table. Use the same criteria syntax as above.

Then simply code the click event:

DoCmd.OpenQuery "AppendQueryName"
DoCmd.SetWarnings False
DoCmd.OpenQuery "DeleteQueryName"
DoCmd.SetWarnings True

You will be prompted just once if you wish to proceed.
 
Back
Top