The following events are all of the events that are raised only once during a report's processing. These events are raised at the beginning and at the end of the report processing cycle.
This event is raised before the DataInitialize event. Use this event to initialize any objects or variables needed while running a report. Also use this event to set any Subreport control objects to a new instance of the report assigned to the Subreport control. Do not add items dynamically to a report once this event has finished.
This event is raised after ReportStart. Use it to add custom fields to the report's Fields collection. Custom fields can be added to a bound report (one that uses a Data Control to connect and retrieve records) or an unbound report (one that does not depend on a data control to get its records). In a bound report the dataset is opened and the dataset fields are added to the custom fields collection, then the DataInitialize event is raised so new custom fields can be added. The DataInitialize event can also be used to make adjustments to the DataSource or to set up database connectivity.
This event is raised if the report's data source does not return any records and if there is no data to be processed. Use this event either to cancel the report or to print a page with a message informing the user that the report did not return any records to print.
This event is raised after the report finishes processing. Use this event to close or free any objects that you were using while running a report in unbound mode, or to display information or messages to the end user. This event can also be used to export reports.
The following ActiveReports events are raised multiple times during a report's processing.
This event is raised every time a new record is processed. The FetchData has an EOF parameter indicating whether the FetchData event should be raised. This parameter is not the same as the Recordset's EOF property and is defaulted to True. When working with bound reports (reports using a DataControl), the EOF parameter is automatically set by the report; however, when working with unbound reports this parameter needs to be controlled manually.
Use the FetchData event with unbound reports to set the values of custom fields that were added in the DataInitialize event or with bound reports to perform special functions, such as combining fields together or performing calculations. The FetchData event should not have any references to controls on the report.
If you need to use a value from a Dataset with a control in the Detail section, set a variable in the FetchData event and use the variable in the section's Format event to set the value for the control. Please note that this method of setting a variable in the FetchData event and using it to set a control's value is only supported in the Detail_Format event.
Also use the FetchData event to increment counters when working with arrays or collections.
This event fires before a page is rendered. Use this event to initialize any variables needed for each page when running an unbound report.
This event is raised after each page in the report is rendered. Use this event to update any variables needed for each page when running an unbound report.
Note: See Scripting to learn about the difference in script and code-behind event handler method definition. |