Writing Event Procedure Code in Two Places

If you write event procedure code for the same event both in the form module and the class module, the code defined in the form class module will run first, followed by the code in the custom class module. You can easily test this by entering the following Form_AfterUpdate event procedure code in the form class module of the frmCustomers or frmProducts forms prepared in Custom Project 27-1:

Private Sub Form_AfterUpdate()

MsgBox "Transferring control to the custom class." ' when you click OK to this message, the code ' inside the AfterUpdate procedure in the custom ' class module will run End Sub

When you open the form and add and save a new record, the Form_ AfterUpdate event will fire and you will see the message about transferring control to the custom class. Next, the AfterUpdate event procedure will run in the custom class, and you will see a message informing you that you can view the audit trail in the specified text file.

0 0

Post a comment