I thought that I had seen your database, but it is no longer there.
Never mind.
Let us assume you have a running total for each detail line of your report, and let us assume that it is called Text152. Let us assume that in the page footer you have a control called Text164 whose ControlSource = "=Text152"
I shall digress here, because gaps in field names in table and gaps in table names are bad news, as everything has to be surrounded by square brackets for use in queries. Equally Text152 & Text164 are equally unhelpful.
A final bit of advice is that all modules should start with
-
Option Compare Database
-
Option Explicit
-
The Option Explicit means that you have to declare your variables which is good practice, and will give a compile error if you make a statement with an incorrect variable spelling.
Back to the problem.
In the Page header section of your report create a text field called "CarriedForward"
-
Option Compare Database
-
Option Explicit
-
-
Dim BF As Currency
-
Dim PageFooterPrinted As Boolean
-
-
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
-
-
BF = Text164
-
-
End Sub
-
-
Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)
-
-
PageFooterPrinted = True
-
If Page = Pages Then ' Last page
-
PageFooterPrinted = False
-
BF = 0
-
End If
-
-
End Sub
-
-
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
-
-
' Only print the CF amount if a Page Footer has previously been printed
-
' and there is a Broght Forward balance
-
If PageFooterPrinted = True Then
-
If BF > 0 Then
-
CarriedForward = "CF:" & CStr(Format(BF, "Currency"))
-
Else
-
CarriedForward = ""
-
End If
-
Else
-
CarriedForward = ""
-
End If
-
-
End Sub
-
-
Private Sub Report_Load()
-
-
' Initialise
-
BF = 0
-
PageFooterPrinted = False
-
-
Me.Text331.Visible = False
-
Me.Text326.Visible = False
-
Me.Text308.Visible = False
-
Me.Text329.Visible = False
-
Me.Text318.Visible = False
-
Me.Text316.Visible = False
-
Me.Text312.Visible = False
-
-
End Sub
-
-
So what happens is that on opening the report (in Print Preview) the Brought forward balance is initialised.
As each Page Footer is Printed (NOT Formatted, because until it is printed, nothing is really fixed) we save the balance.
As each Page Header is formatted, unless it's Page 1, we print the Balance we have just saved.
Phil