Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print page totals in your reports 3

Status
Not open for further replies.

CosmoKramer

Programmer
May 29, 2001
1,730
US
This can be done with just a little bit of code........

Add an unbound text box to your detail section (for example, txtSum) and set it to be invisible.

In the On Format event of your page header section, put the following code:

Code:
txtSum = 0
This will reset the variable to 0 for each new page.

In the On Format event of your detail section, put the following code, of course changing txtFieldToBeSummed to your field to calculate:

Code:
txtSum = txtSum + txtFieldToBeSummed

Add a text box to your page footer to display the page total. Set its control source to =[txtSum] which holds the last running sum amount.
 
Cosmo, I've been working with your example and am getting the wrong values in the pagefooter textbox. Here is what I'm seeing. The example shows the last three records on the first page, records 38, 39 and 40 and the first record on the second page record # 41. In between the page footer shows a value that is larger, by the value of the first record on the next page, than the last value in the running total column. The example shows the same problem for each page in the report.

Code:
Rec#     Value       RunningTotal
38         2.00           46.5
39         2.00           48.5
40         1.00           49.5

PageFooter Value reads  50.5

41          1

77          1.00          46
78          0.25          46.25
79          5.00          51.25

PageFooter Value reads   51.75

80          0.50

Any thoughts.  I've set the report up just the way you indicated but can't get the values to work.  I've stepped thru the code so I could see what happens.  When stepping thru the format event for the detail section, it adds the value of the first record on the following page to the total of the preceeding page but doesn't display it on the first page. It's kind of unusual.  Could you check it out and let me know what you think.

Thanks

Paul
 
Just as an update, if I insert code to limit the number of records on each page, everything seems to work well. All the numbers came out correct.

Paul
 
Thanks Duane, I'll try that.

Paul
 
how can i print the page total at the end of each page?
 
Did you try any of the solutions listed in this thread?

Duane
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top