Thanks guys for responding to my post.
MGFoster & Tom
My application is a time keeping system.
My GroupFooter1 is Employee. In the Detail Section I show start and
end times for given dates. In GroupFooter1 I total up the hours using
a Sum(EndTime-StarTime) and then I have a calculated control in
GroupFooter1 that uses a DLookup to get the charge rate for that
employee and multiply it times the total hours for that employee.
Something like:
GroupFooter1
Control Name = tbAtStandard
Control Source = DLookup(EmployeeRate) X Sum(EndTime-StartTime)
This seems to work fine.
The problem comes in accumulating tbAtStandard for all employees in
GroupFooter0 which is Client. I'm not sure if and how I can use the
RunningSum property to get the result. If I set up in GroupFooter0 a
textbox with control source = sum(tbAtStandard), when I run the report
it asks me to input tbAtStandard.
That is why I have tried to use code to keep a running total of
tbAtStandard. Since my first post I have tried putting my code into
the Format events instead of the Print events but I still don't get
the correct results.
MGFoster
I don't think I can use your suggestion which relies on calculations
in the detail section because the EmployeeRate changes with each new
GroupFooter1.
Am I missing something obvious?
Many thanks.
Regards,
Bill Dika
Tom van Stiphout <to*****@no.spam.cox.net> wrote in message news:<br********************************@4ax.com>. ..
On 14 Nov 2003 12:28:02 -0800, bd*****@yahoo.com (Bill Dika) wrote:
It seems you're writing code to calculate the sum. This code may be
called multiple times by Access. That's what the PrintCount argument
is for. Set a breakpoint and you'll see what I mean. Even "if
PrintCount = 1" to me seems a bit too scary. For example your function
may be called again with PrintCount=1 if you first preview the report
and then print it from there.
The standard way of calculating a running sum is to specify this at
design time in a control. See the RunningSum property of a textbox.
Try that first.
-Tom.
Hi
I am trying to calculate a running total of a calculated textbox
(tbAtStandard) in GroupFooter1 for placement in a textbox
(tbTotalAtStandard) on my report in Groupfooter0.
The problem that I am having is that sometimes the correct total shows
up in print preview and sometimes it doesn't. Sometimes it is higher
and sometimes it is lower (than the correct amount) and I cannot make
any sense of the difference. The difference seemingly does not tie
into anything on the report (e.g. double counting an item or leaving
off an item). Another anomaly is that the print preview and the actual
printing sometimes produce different results, again without any
pattern (but sometimes correct).
The code I am using seems to me to be quite simple and is as follows:
Option Compare Database
Dim vbatbAtStandard As Double
Dim vbatbAtCost As Double
Private Sub GroupFooter0_Print(Cancel As Integer, PrintCount As
Integer)
'------ post the running sum to the report and zero the variable
for next group -------
Me!tbTotalAtStandard = vbatbAtStandard
vbatbAtStandard = 0
'---------------------------------------------------------------------------
Me!tbTotalAtCost = vbatbAtCost
vbatbAtCost = 0
End Sub
Private Sub GroupFooter1_Print(Cancel As Integer, PrintCount As
Integer)
If PrintCount = 1 Then
'------- calculate the running sum --------
vbatbAtStandard = vbatbAtStandard + Me!tbAtStandard
'------------------------------------------
vbatbAtCost = vbatbAtCost + Me!tbAtCost
End If
End Sub
Any help would be much appreciated.
Regards,
Bill Dika