MS-Access / Getting Started

Report section event procedures

In addition to the event properties for the form itself, Access offers three specialized event properties to use with report sections. Table-7 shows each property, the event it recognizes, and how it works.

Table-7: Report Section Events
EventWhen the Event Is Triggered
FormatWhen the section is pre-formatted in memory before being sent to the printer. This is your opportunity to apply special formatting to controls within the section.
PrintAs the section is sent to the printer. It is too late to format controls in a report section when the Print event fires.
RetreatAfter the Format event but before the Print event. Occurs when Access has to back up past other sections on a page to perform multiple formatting passes. Retreat is included in all sections except headers and footers.

The Format event

Use the Format event to apply special formatting to controls within a section before the section is printed. Format is useful, for example, to hide controls you don't want to print because of some condition in the report's data. The event procedure runs as Access lays out the section in memory but before the report is sent to the printer.

You can set the On Format and On Print event properties for any section of the report. However, OnRetreat is not available for the page header or page footer sections.

Form PivotTable events

The more recent versions of Access include the ability to create pivot tables that display data in interesting ways. You might encounter pivot tables as you work with Microsoft Access. Because of the special requirements imposed by pivot tables, Access forms include a number of events, as shown in Table-8.

An Access pivot table is actually a special view of a table, created by selecting PivotTable View from the View group in the Home tab while a table is open in Datasheet view. A pivot chart is created from a table open in Datasheet view by clicking on the PivotChart button in the Forms group on the Create tab of the Access ribbon.

Table-8: Form PivotTable Events
EventWhen the Event Is Triggered
TimerWhen a specified time interval passes
TimerIntervalWhen the interval is specified in milliseconds
BeforeScreenTipWhen a screen tip is activated
CmdEnabledWhen a command has become enabled in a pivot chart or pivot table
CmdCheckedWhen a pivot chart or pivot table command has been selected
CmdBeforeExecuteWhen a PivotChart or PivotTable command has been selected from the ribbon, but not yet executed
CmdExecuteImmediately after a pivot table or pivot chart command has been executed
DataChangeWhen a pivot table or pivot chart's data is changed or refreshed
DataSetChangeWhen a new data set for the chart changes (for example, when filtered)
PivotTableChangeWhenever the list field, field set, or total is added or deleted in a pivot table
SelectionChangeWhen a user makes a new selection; cannot be canceled
ViewChangeWhen a different PivotTable view of the current data is opened
ConnectWhen a pivot table connects to the underlying recordset
DisconnectWhen a pivot table disconnects from the underlying recordset
BeforeQueryWhen a pivot table is about to get a new data object
QueryWhen the pivot table receives a new data object
AfterLayoutWhen the pivot chart has already been laid out but before any rendering is done
BeforeRenderWhen the pivot chart is about to paint itself on the screen (before drawing begins)
AfterRenderWhen the object has been rendered in the pivot chart
AfterFinalRenderWhen all the chart objects have been rendered
[Previous] [Contents] [Next]