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 EventsEvent | When the Event Is Triggered |
---|---|
Format | When 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. |
As the section is sent to the printer. It is too late to format controls in a report section when the Print event fires. | |
Retreat | After 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 EventsEvent | When the Event Is Triggered |
---|---|
Timer | When a specified time interval passes |
TimerInterval | When the interval is specified in milliseconds |
BeforeScreenTip | When a screen tip is activated |
CmdEnabled | When a command has become enabled in a pivot chart or pivot table |
CmdChecked | When a pivot chart or pivot table command has been selected |
CmdBeforeExecute | When a PivotChart or PivotTable command has been selected from the ribbon, but not yet executed |
CmdExecute | Immediately after a pivot table or pivot chart command has been executed |
DataChange | When a pivot table or pivot chart's data is changed or refreshed |
DataSetChange | When a new data set for the chart changes (for example, when filtered) |
PivotTableChange | Whenever the list field, field set, or total is added or deleted in a pivot table |
SelectionChange | When a user makes a new selection; cannot be canceled |
ViewChange | When a different PivotTable view of the current data is opened |
Connect | When a pivot table connects to the underlying recordset |
Disconnect | When a pivot table disconnects from the underlying recordset |
BeforeQuery | When a pivot table is about to get a new data object |
Query | When the pivot table receives a new data object |
AfterLayout | When the pivot chart has already been laid out but before any rendering is done |
BeforeRender | When the pivot chart is about to paint itself on the screen (before drawing begins) |
AfterRender | When the object has been rendered in the pivot chart |
AfterFinalRender | When all the chart objects have been rendered |