The remainder of this chapter will apply all of the information covered in the above sections to get you started on the automation of Access Reports. The examples are in no particular order and possibly do not rely on each other for reader comprehension. In case an example is associated to another, it will be noted. This allows for the reading of only the property examples that are pertinent to you.
The On Open event procedure works just like the On Open event procedure of forms, in that it is triggered when the form is opened. The functionality that can be placed within this event procedure is unlimited, but it is important to keep in mind that the code will trigger only once. If there is a repetitive task that needs to execute throughout the report, then the code should be moved to a different event procedure.
There are many things that may need to happen when a report is opened, but one task could be the preparation of data, just prior to printing. It is not uncommon in Access to base a report on a table that is used specifically for the report. There could be some complex calculations or last minute processing that need to be done before the report can print correctly.
For example, suppose that you need to execute a Delete Query, an Append Query, and an Update Query prior to printing a report. The Delete Query would be used to empty any previous data from the report table, ...