HandsOn Writing the Form PivotTable Change Event Procedure

1. In the Visual Basic Editor window, double-click Form_Sales Analysis Subform 1.

2. The Code window shows several event procedures you prepared earlier in this chapter. Enter the following Form_PivotTableChange event procedure below the last procedure code.

Part IV

Private Sub Form_PivotTableChange(ByVal Reason As Long) If Reason = OWC11.plPivotTableReasonTotalAdded Then MsgBox "Just added a Total." End If End Sub

3. To test the above event procedure, open Sales Analysis Subform 1 in Form view. Because you've already created several event procedures for this form, various events will be triggered. Respond appropriately to the prompts. During the course of events, you should see the message informing you that a Total field has just been added.

0 0

Post a comment