Reports: Page Totals

        Not Rated      3,737 views      0 comments
by Allen Browne, 20 April 2005    (Access 2+)

Microsoft Access Tips for Serious Users

Provided by Allen Browne, allen@allenbrowne.com


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!

  1. In the PageHeader's Format event procedure, add:
        curTotal = 0             'Reset the sum to zero each new Page.
  2. In the DetailSection's Print event, add:
        If PrintCount = 1 Then curTotal = curTotal + Me.Amount
  3. Place an unbound control called PageTotal in the Page Footer. In the PageFooter's Format, add:
        Me.PageTotal = curTotal
  4. In the Code Window under Declarations enter:
        Option Explicit          'Optional, but recommended for every module.
        Dim curTotal As Currency 'Variable to sum [Amount] over a Page.

That's it!


Home Index of tips Top

Rate this article:   Your rating: Poor Your rating: Not so good Your rating: Average Your rating: Good Your rating: Excellent


This is a cached tutorial, reproduced with permission.

Have your say - comment on this article.

What did you think of 'Reports: Page Totals'?

No comments yet.

Why not be the first to comment on this article?!

Have your say...

Name
E-mail (e-mail address will be kept private)
Comments
Verify Code
Verification Code


It may take 30 seconds after clicking submit - please be patient to avoid duplicate submissions.  

All comments must be approved before being displayed on this web page.  This process may take up to 24 hours.