This hands-on uses the Product Categories form created in Hands-On 24-6.
1. In the Visual Basic Editor window, double-click Form_Product Categories.
2. The Code window appears with several event procedures that were prepared in previous hands-on exercises. Enter the following Form_After-DelConfirm event procedure below the last procedure code.
Private Sub Form_AfterDelConfirm(Status As Integer) MsgBox "The selected record was deleted." Debug.Print "Status = " & Status End Sub
Event Programming in Forms and Reports
3. To test the above event procedure, switch to the Product Categories form and open it in Form view.
4. Add a new record, save it, and delete it. Access will execute the code in the Form_Delete event procedure (Hands-On 24-7) that displays a message box asking you whether you want to delete the record. Click Yes. Access will then check the code in Form_BeforeDelConfirm (Hands-On 24-8). The statement Response = acDataErrContinue will cause Access to suppress its default Delete Confirm dialog box and you will not be prompted again to reconfirm the deletion. Finally, Form_AfterDelConfirm will run and you will see a message about the successful deletion.
5. Close the Product Categories form.
Was this article helpful?