HandsOn Writing the Report Activate Event Procedure

This hands-on uses the rptCustomers report created in Hands-On 25-1.

1. Create a custom toolbar named Printing Reports with the buttons as shown in Figure 25-1 below. (Refer to the online help for detailed instructions on how to design Access toolbars.)

Note: Some of the toolbar buttons that you can see in Figure 25-1 do not appear in the Customize dialog box. However, you can steal them from the built-in Print Preview toolbar. Design your custom Printing Reports toolbar while in the Report Print Preview screen where the Print Preview toolbar is visible by default. Then, use the Customize dialog box to create a new toolbar named Printing Reports. Hold down the Ctrl key while dragging the required button from the Print Preview toolbar to your Printing Reports toolbar. Other buttons can be found on the Commands tab in the Customize dialog box.

¡Printing Reports

Figure 25-1: When a report is activated you may want to display a custom toolbar like this one.

Part IV

2. In the Visual Basic Editor Code window for the rptCustomers report, type the following Report_Activate event procedure:

Private Sub Report_Activate()

DoCmd.ShowToolbar "Print Preview", _

acToolbarNo DoCmd.ShowToolbar "Printing Reports", _ acToolbarYes

End Sub

3. Open the rptCustomers report and type your criteria when prompted. Upon activation of the report, the code you placed in the Report_Activate event procedure will run, causing the default Print Preview toolbar that Microsoft Access normally displays to be hidden and your custom toolbar to appear.

0 0

Post a comment