HandsOn Writing the Detail DblClick Event Procedure

1. In the Database window, open the Product Categories form in Design view. Recall that you created this form in Hands-On 24-6.

2. Turn on the header and footer by choosing View | Form Header/Footer.

3. Increase the size of the header and footer so that they are visible when you run the form.

4. Click the Form Detail to select it, and then click the Properties button on the toolbar.

5. In the Section Detail properties sheet, click the Event tab and select [Event Procedure] next to the DblClick property name. Click the Build button

(...) to move directly to the event procedure.

6. In the Code window, you should have the stub of the Detail_DblClick event procedure already written for you. Complete this procedure as shown below.

Private Sub Detail_DblClick(Cancel As Integer) With Me

.Section(acHeader).BackColor = _ RGB(Rnd * 128, _ Rnd * 256, _ Rnd * 255) .Section(acDetail).BackColor = _ RGB(Rnd * 128, _ Rnd * 256, _ Rnd * 255) .Section(acFooter).BackColor = _ RGB(Rnd * 128, _ Rnd * 256, _ Rnd * 255)

End With End Sub

Part IV

7. To test the above event procedure, open the Product Categories form in Form view. Double-click anywhere in the Detail section of the form and see the colors of the Detail, Header, and Footer sections change.

0 0

Post a comment