11.4. Important Report Events and Properties

The following sections examine the most common events on reports that you will need to use in the course of developing your applications. These events occur when opening a report, when you work with sections and controls, and when you close a report. You can find a more comprehensive list of report events and the order in which they fire in Appendix G.

11.4.1. Opening a Report

The Open, NoData, Load, and Current events are important events that are necessary to implement many Access solutions. The Load and Current events are new to reports in Access 2007.

11.4.1.1. Open Event

Open is the first event that fires when you open a report. It's fired before Access fetches the data for the report, which means that you can dynamically create or alter the query for the report based on user input or the state of controls on another form or report in the database.

You can also cancel the Open event. If you set the Cancel argument of the event to true, Access stops loading the report, no further events fire, and the report is not displayed on screen. This is useful when you want to ensure that the application is in a certain state before opening the report. For instance, you might want a particular user logged in or a particular form open before opening the report.

If you have a report and you want it to display data from the last 30 days of sales, for example, you can modify the report's RecordSource property when the report is opened to restrict ...

Get Access™ 2007 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.