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

Private Sub Form_CommandChecked(ByVal Command As Variant, _

ByVal Checked As Object)

If Command = OWC11.plCommandSortAsc Then If Checked.Value = True Then

Event Programming in Forms and Reports

Debug.Print "Sort Ascending command is checked." Else

Debug.Print "Sort Ascending command unchecked." End If End If End Sub

3. To test the above event procedure, clear the Immediate window by selecting all the text and pressing Delete. Next, 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, click the SortDescending button on the toolbar. Switch to the Immediate window to see the results of the events that were executed.

0 0

Post a comment