ACC97: Incorrect Totals Occur When You Print or Preview a Report (326453)



The information in this article applies to:

  • Microsoft Access 97

This article was previously published under Q326453
Moderate: Requires basic macro, coding, and interoperability skills.

SYMPTOMS

When you perform calculations in a report, the calculations may be incorrect when you print from the Print Preview view or when you preview the report.

CAUSE

You are programmatically calculating your totals. The totals are calculated by using a report event that fires per page. Each page must be previewed to fire that event for that page and then calculate the correct totals.

RESOLUTION

You can use one of the following methods to work around this issue:

Method 1

Print the Report Without Previewing:

Print the report without first previewing the report.

Method 2

Save the Report As a Snapshot:
  1. Open the report in Print Preview.
  2. On the File menu, click Save As/Export.
  3. In the Save As dialog box, click to select To an external file or database and then click OK.
  4. In the Save as type drop-down list, click to select Snapshot Format, specify the name and location for your snapshot file, and then click Export.
For additional information about report snapshots and Microsoft Snapshot Viewer, click the article number below to view the article in the Microsoft Knowledge Base:

172348 ACC97: Report Snapshots and Microsoft Snapshot Viewer

Method 3

Scroll Through All Pages of the Report:

  1. Open the report in Print Preview.
  2. Use the navigation buttons to scroll through all pages of your report.

Method 4

Put Calculations in an Underlying Query:

If possible, put calculations in an underlying query instead of on the report.

Method 5

View Multiple Pages at a Time:
  1. Open the report in Print Preview.
  2. On the View menu, point to Pages and then select the number of pages that you want to view.

MORE INFORMATION

This behavior has been changed in Microsoft Access 2002.

Steps to Reproduce the Behavior

  1. Open the sample database Northwind.mdb.
  2. Close the Startup screen and the Switchboard form if they appear.
  3. Click Reports under Objects and then click New.
  4. In the New Table dialog box, click to select AutoReport: Columnar, select the Employees table from the Choose the table or query where the object's data comes from drop-down list, and then click OK to preview the report.
  5. Close the report and then save it as EmployeesTest.
  6. Open the EmployeesTest report in Design view.
  7. Add a Text Box to the "Report Footer" section and name it GrandTotal.
  8. On the View menu, click Code.
  9. Type or paste the following code in the "General Declarations" section:
    Public Total as Integer
    					
  10. Type or paste the following code on the OnPrint event of the "Detail" section:
    'Count the number of records where the country is USA
    If Me!Country = "USA" Then
      Total = Total + 1
    End If
    					
  11. Type or paste the following code on the OnPrint event of the "Report Footer" section:
    'Put the total in the GrandTotal field
    Me!GrandTotal = Total
    					
  12. On the File menu, click Close to close the code module.
  13. On the View menu, click Print Preview.
  14. Click the navigation button at the bottom of the report to go directly to the last page without scrolling through any other pages on the report.
  15. Note that the value in the GrandTotal field is incorrect.

Modification Type:MajorLast Reviewed:10/20/2003
Keywords:kbprb KB326453