473,396 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Page totals off by one record ? Please help :)

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
2 1693
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ddecoste | last post by:
I have done a bunch of looking but I am confused as to the correct way I should proceed with this problem. I have query that returns: It is sorted by ordnum then, linenum, then date and it...
2
by: CaptainDahlin | last post by:
I know the basics about access reports and putting page totals in the page footers. What I can't figure out is along with the current page total to display the previous page total: At the bottom...
3
by: igotyourdotnet | last post by:
I'm using a gridview and I have it formatted using sub headings. now I need to get totals for each sub heading. Is this possible? example: BMW (sub heading) 25,000 14,252 25,000 total:...
2
by: Tom | last post by:
All: I have a report that lists quantities of stuff used over the course of a year and it is grouped on each month. In the group footer I want to insert the total for the month - easy stuff so...
9
by: JJM0926 | last post by:
I'm trying to create a running totals query in access 97. I have followed the directions on how to do it from Microsofts website article id 138911. I took their code they had and replaced it with...
4
by: Micheal | last post by:
Greetings Access Group, Being relatively new to Access, I try to work through problems on my own and have been very successful, although I have a conundrum that I have been working on for two days...
2
by: Ron | last post by:
Hi All, I've got a main form (frmMain) with 5 subforms on it. All subforms are linked to different hidden controls on frmMain. The purpose of this form is to record payments by 'source'...
1
by: maffonso | last post by:
Hi guys, I have created a VB code through 'Record a new Macro'. This code builds a pivot table.The problem is that the table created has totals but Id like a pivot table without totals. How can i...
0
it0ny
by: it0ny | last post by:
Hi guys, thanks I am fairly new to this forum so I hope I chose the right place to post this question. I try to make my program printout a deposit's report. I created a class to store the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.