Working with Report Events

At this point, you should be very familiar with how to add events to forms, such as the Click event of a button. Reports have events just as forms do, but not as many, as you can see in Figure 8.5.

W Report

Report V-

Format Data Event other All

On Close

On Activate

On Deactivate

On No Data

On Paoe

On Error

V

You can also write VBA code behind report events, such as Open, Close, Activate, and Deactivate. For example, you might want to display a message to users when the report opens to inform them that the report will take a long time to load. You may want to add a custom toolbar to be displayed from the Activate event and then remove that toolbar when the Deactivate event fires.

The following is an example of adding and removing a custom toolbar from the report's Activate and Deactivate events.

acToolbarYes

Private

Sub Report_Deactivate()

DoCmd.

.ShowToolbar "CustomComplaints",

acToolbarNo

End Sub

Now that you have a basic idea of how to create reports programmaticaUy and how to create report events, you can move on to the topic of exporting Access data to various Web formats.

0 0

Post a comment