Provided by Allen Browne, firstname.lastname@example.org
Reports: Page Totals
Each section of a report has a Format event, where you can alter properties such as Visible, Color, Size, etc in a manner similar to the Current in a form. (See Runtime Properties: Forms for details.) For example to force a page break when certain conditions are met, include a PageBreak control in the Detail Section and toggle its Visible property. In addition, the Print event can be used to perform tasks like adding the current record to a running total.
You have an Amount field, and want to display the Amount total for that page in the Page Footer. Totals are not normally available in the Page Footer, but the task requires just four lines of code!
- In the PageHeader's Format event procedure, add:
curTotal = 0
- In the DetailSection's Print event, add:
If PrintCount = 1 Then curTotal = curTotal + Me.Amount
- Place an unbound control called PageTotal in the Page Footer. In the PageFooter's Format, add:
Me.PageTotal = curTotal
- In the Code Window under Declarations enter:
Dim curTotal As Currency