Report Section.
The Format event occurs when Microsoft Access determines which data belongs in a report section, but before Microsoft Access formats the section for previewing or printing.
A Format event occurs for each section in a report. This allows you to create complex running calculations using data from each section, including sections that aren’t printed.
For report detail sections, the Format event occurs for each record in the section just before Microsoft Access formats the data in the record. A Format macro or event procedure has access to the data in the current record.
For report group headers, the Format event occurs for each new group, and a Format macro or event procedure has access to data in the group header and data in the first record in the detail section. For report group footers, the Format event occurs for each new group, and a Format macro or event procedure has access to the data in the group footer and the data in the last record in the detail section.
By running a macro or running an event procedure when the Format event occurs, you can use data in the current record to make changes to the report that affect page layout. For example, you can display or hide a congratulatory message next to a salesperson’s monthly sales total in a sales report, depending on the sales total. After the control is displayed or hidden, Microsoft Access formats the section using the values of format properties, such as CanGrow, CanShrink, HideDuplicates, KeepTogether, and Visible.
For changes that don’t affect page layout or for event procedures or macros that should run only after the data on a page has been formatted, such as a macro that prints page totals, use the Print event for the report section.
There are times when Microsoft Access must return to previous sections on a report to perform multiple formatting passes. When this happens, the Retreat event occurs as the report returns to each previous section, and the Format event occurs more than once for each section. You can run a macro or event procedure when the Retreat event occurs to undo any changes that you made when the Format event occurred for the section. This is useful when your Format macro or event procedure carries out actions, such as calculating page totals or controlling the size of a section, that you want to perform only once for each section.
FormatCount Property, NoData Event, Page Event, Print Event, PrintCount Property, Retreat Event.