Re: Page totals error in report - doesn't add correctly



Geoff wrote:

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


That code that you're using isn't supposed to do what you
say you want. I suspect that there may be more to using
that code than just copying it, because there are several
caveats to using an event procedure to calculate a total.
In almost all cases that code can not reliably calculate a
correct total.

Using the Sum function is the right way to do this if Hours
is a field in the report's recordsource table/query.
(Otherwise, you can use a RunningSum text box to add up the
total.)

The first thing I would suspect is that the Hours is somehow
being converted to an integer. To check this, try setting
the Hours text box in the detail section and all the group
and report footer text boxes to use the format 0.000000000
so you can see the whole value.

The next thing to check is the actual, not the formatted,
values in the recordsource table/query. Applying a format
to the table and query just obscurs the values used in the
calculations.

--
Marsh
MVP [MS Access]
.



Relevant Pages

  • Re: Page totals error in report - doesnt add correctly
    ... display it on a form or report. ... query based on the Import Table. ... All Totals text boxes properties are set to General number with 2 decimal ...
    (microsoft.public.access.reports)
  • Re: Group Totals
    ... The report displays the detail records and their dollar amount. ... I want to be able to display this ... I initially thought I'd be able to keep track of the InvoiceNumber using ... >>the next page and attempts to display my totals, ...
    (microsoft.public.access.reports)
  • Re: Group Totals
    ... Now it souds like it just a matter of formatting the report ... OTOH maybe you are struggling with calculating the invoice ... I want to be able to display this ... >>>the next page and attempts to display my totals, ...
    (microsoft.public.access.reports)
  • Re: Need report help! repeating data....
    ... also doesn't display some of the projects. ... I also have a report setup the other way you suggested, with the subreport, ... For each project I have a totals field, ... projects payments. ...
    (microsoft.public.access.reports)
  • Re: Getting totals for certain fields in Access 2002
    ... and need to run a report to get totals from a couple of fields. ... Create a report with a header for the call count total ... In the call count header and report footer create a field that shows ...
    (microsoft.public.access.gettingstarted)

Loading