HandsOn Writing the Form ViewChange 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_ViewChange event procedure below the last procedure code.

Private Sub Form_ViewChange(ByVal Reason As Long) Select Case Reason

Case OWC11.plViewReasonHideDetails

MsgBox "You selected to hide the details." Case OWC11.plViewReasonShowDetails

MsgBox "You selected to show the details." End Select 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. Once the form opens in the PivotTable view, click the Show/Hide Details (+ /-) button below any employee name.

0 0

Post a comment