By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,404 Members | 2,512 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,404 IT Pros & Developers. It's quick & easy.

Page totals off by one record ? Please help :)

P: n/a
I am just going crazy.

I have a report that requires page totals. I got the report
working, except that my page has ELEVEN records (ok), but
the page total includes data on the TWELFTH record.

I've started over from scratch and still have the same result.

I am very grateful to anyone helping to resolve this crippling issue.

Here's my code:
------------------------------------------------------------------------------------------------------------------
[1] nPage_res = variable to accumulate "hour_res," a field in the
table

[2] me.Hour_res = field in table I wish to accumulate and display a
page total for.

[3] Me.Page_Res = unbound control in the Page Footer
-------------------------------------------------------------------------------
This results in the report displaying 11 records per page,
with the total residential hours including the 12th record.
Arrrrggggggggggghhhhhhh!!

Author: Louis Hemmi
Date: 9/11/2004
-----------------

Option Explicit
Dim npage_res As Long 'variable acting as accumulator
Option Compare Database

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If PrintCount = 1 Then npage_res = npage_res + Me.Hour_res

' if there's a record, update page_res with hour_res
End Sub

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)

Me.Page_Res = npage_res

' unbound control now equals the accumulated total for page
' me.hour_res is the last displayed hour_res on the page
' but total still includes the next page's first record

End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)

npage_res = 0 'reset the accumulator

End Sub

Thanks very much,

Louis
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Use the Print event of the detail section to accumulate your total, not its
Format event.

The Format event can fire multiple times for the same record, and would have
to use the Retreat event as well as testing FormatCount (not PrintCount) if
you wanted to use this event.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Louis1" <louis@_n0sp3m_HoustonBookClub.com> wrote in message
news:gb********************************@4ax.com...
I am just going crazy.

I have a report that requires page totals. I got the report
working, except that my page has ELEVEN records (ok), but
the page total includes data on the TWELFTH record.

I've started over from scratch and still have the same result.

I am very grateful to anyone helping to resolve this crippling issue.

Here's my code:
------------------------------------------------------------------------------------------------------------------
[1] nPage_res = variable to accumulate "hour_res," a field in the
table

[2] me.Hour_res = field in table I wish to accumulate and display a
page total for.

[3] Me.Page_Res = unbound control in the Page Footer
-------------------------------------------------------------------------------
This results in the report displaying 11 records per page,
with the total residential hours including the 12th record.
Arrrrggggggggggghhhhhhh!!

Author: Louis Hemmi
Date: 9/11/2004
-----------------

Option Explicit
Dim npage_res As Long 'variable acting as accumulator
Option Compare Database

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If PrintCount = 1 Then npage_res = npage_res + Me.Hour_res

' if there's a record, update page_res with hour_res
End Sub

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)

Me.Page_Res = npage_res

' unbound control now equals the accumulated total for page
' me.hour_res is the last displayed hour_res on the page
' but total still includes the next page's first record

End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)

npage_res = 0 'reset the accumulator

End Sub

Thanks very much,

Louis

Nov 13 '05 #2

P: n/a
That worked like a charm !

Thanks very much :)

Louis
Houston, Texas

On Sun, 12 Sep 2004 16:00:02 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
Use the Print event of the detail section to accumulate your total, not its
Format event.

The Format event can fire multiple times for the same record, and would have
to use the Retreat event as well as testing FormatCount (not PrintCount) if
you wanted to use this event.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Louis1" <louis@_n0sp3m_HoustonBookClub.com> wrote in message
news:gb********************************@4ax.com.. .


Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.