G
Geoff
I am trying to print the total number of hours billed to a client in a
report. Initially this was displayed in a textbox with the source set to the
expression "=Sum([Hours]). This works fine on the one report which displays
the decimals correctly in the report footer, but won't work at all on the
other report where the total should read 266.85 hours but instead will only
display 266 hours.
Then I used Allen Browne's Page Total code and discovered that the problem
is caused by the total hours for the first page which are displayed
incorrectly (adds up to 10 whereas it should be 10.83). The total hours all
display correctly in the group footers but won't do so in the report footer.
All Totals text boxes properties are set to General number with 2 decimal
places - as is the data in the source query and table.
Why does one report work fine and the other not? I've even completely
rebuilt a new report from the one that works, but to no avail - still gives
the wrong total. Can anyone help? Thanks
Allen Browne's code that I used was as follows:
Option Compare Database
Dim HoursTotal As Long
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If PrintCount = 1 Then HoursTotal = HoursTotal + Nz(Me.Hours, 0)
End Sub
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
Me.PageTotal = HoursTotal
End Sub
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
HoursTotal = 0
End Sub
report. Initially this was displayed in a textbox with the source set to the
expression "=Sum([Hours]). This works fine on the one report which displays
the decimals correctly in the report footer, but won't work at all on the
other report where the total should read 266.85 hours but instead will only
display 266 hours.
Then I used Allen Browne's Page Total code and discovered that the problem
is caused by the total hours for the first page which are displayed
incorrectly (adds up to 10 whereas it should be 10.83). The total hours all
display correctly in the group footers but won't do so in the report footer.
All Totals text boxes properties are set to General number with 2 decimal
places - as is the data in the source query and table.
Why does one report work fine and the other not? I've even completely
rebuilt a new report from the one that works, but to no avail - still gives
the wrong total. Can anyone help? Thanks
Allen Browne's code that I used was as follows:
Option Compare Database
Dim HoursTotal As Long
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If PrintCount = 1 Then HoursTotal = HoursTotal + Nz(Me.Hours, 0)
End Sub
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
Me.PageTotal = HoursTotal
End Sub
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
HoursTotal = 0
End Sub