Rolling Totals In Report

  • Thread starter Thread starter HuskerJeff
  • Start date Start date
H

HuskerJeff

I am trying to put a rolling total in an access report. I need to put it in
the page hader, footer, and on each line. I think I want to make it a public
variable, but when I do that, it looks like this:

Option Compare Database
Public curRollBalBen As Currency
Public curRollBalGen As Currency
Public curRollBalSoc As Currency
Public curRollBalBld As Currency


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
curBrtForBen = curRollBalBen + BReceipts - BExpenditures
curBrtForGen = curRollBalGen + GReceipts - GExpenditures
curBrtForSoc = curRollBalSoc + SReceipts - SExpenditures
curBrtForBld = curRollBalBld + BuildReceipts - BuildExpenditures
CurDetBalBen = curBrtForBen
CurDetBalGen = curBrtForGen
CurDetBalSoc = curBrtForSoc
CurDetBalBld = curBrtForBld

End Sub

Then I get an error "The expression onformat you have entered as the event
property setting produced the following error: can't execute code in design
mode.

If I dim it in one of the subs, I can't set it public, but if I set it
private, everything runs but the value is not carried to the other modules.

What am I doing wrong?
 
If you only need to use those variables within the report, declaring them
Private at the top of the report's code section is good enough. All
procedures in the report module will be able to reference them. If you need
to reference those values outside of the report module, declare the variables
as Public in a separate code Module. Just remember to initialize them
whenever the report is opened.
 
Back
Top