Retreat

The Retreat event occurs when Microsoft Access returns to previous sections of the report during report formatting. For example, after formatting a report section, if Access discovers that the data will not fit on the page, it will go back to the necessary location in the report to ensure that the section can properly begin on the next page.

The Retreat event occurs after the Format event but before the Print event. This event applies to all report sections except page headers and footers. The Retreat event occurs for group headers and footers whose KeepTogether property has been set to Whole Group or With First Detail. This report is also triggered in subreports whose CanGrow or CanShrink properies have been set to True.

The Retreat event makes it possible to undo any changes made during the Format event for the section.

The Retreat event is demonstrated in the sample Northwind database's Sales by Year report as shown in Figure 25-6.

Figure 25-6: The Sales by Year report in the Northwind database uses the GroupFooter1_ Retreat event procedure to control printing of a page header.

Si Northwind - Report_Sales by Year (Code)

|Gioii|>Footei1 |Relie.it

Private Sub GroupFooter1_Retreat(] ' If ShowDetails check box on Sales by Year Dialog form b checked, 1 set value of Show teod box lo True ao that page header will print on ' next page.

3

If Forms! [Sales by Year Dialog] I ShowDetails ffhen MelShow.Value

= True

End Sub

Figure 25-6: The Sales by Year report in the Northwind database uses the GroupFooter1_ Retreat event procedure to control printing of a page header.

0 0

Post a comment