473,396 Members | 1,921 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.

Code for Access Report group page numbers not returning the correct values

I'm trying to get an Access report to print the number of pages of the group instead of the number of the whole report. The code I'm using is below. The Debug statement in the middle shows that the array is being built properly but the results on the report show the wrong number of pages in the groups.

For example, the first group has 5 pages. The array comes out as:
1, 2
2, 2
1, 3
2, 3
3, 3
1, 4
2, 4
3, 4
4, 4
1, 5
2, 5
3, 5
4, 5
5, 5

So it seems to end with the correct values (page 1 of 5, page 2 of 5... page 5 of 5), but when the report prints, it prints Page 1 of 3, Page 2 of 3, Page 3 of 3, Page 4 of 4, and Page 5 of 5.

The second group is 2 pages long, but it prints Page 1 of 3 and Page 2 of 3.

Any help would be much appreciated! Thank you!

Expand|Select|Wrap|Line Numbers
  1. Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
  2. 'NOT WORKING
  3. 'This code was originally written by James H Brooks.
  4. 'It is not to be altered or distributed, except as part of an application.
  5. 'You are free to use it in any application,
  6. 'provided the copyright notice is left unchanged.
  7. 'Code Courtesy of James H Brooks.
  8.  
  9.     If Me.Pages = 0 Then    
  10.         ReDim Preserve GrpArrayPage(Me.Page + 10)
  11.         ReDim Preserve GrpArrayPages(Me.Page + 10)
  12.         GrpNameCurrent = Me!AG
  13.         If GrpNameCurrent = GrpNamePrevious Then
  14.             GrpArrayPage(Me.Page) = GrpArrayPage(Me.Page - 1) + 1
  15.             GrpPages = GrpArrayPage(Me.Page)
  16.                 For ThisPage = Me.Page - ((GrpPages) - _1) To Me.Page
  17.                     GrpArrayPages(ThisPage) = GrpPages
  18. Debug.Print CStr(GrpArrayPage(ThisPage)) + ", " + CStr(GrpArrayPages(ThisPage))
  19.                 Next ThisPage
  20.         Else
  21.             GrpPage = 1
  22.             GrpArrayPage(Me.Page) = GrpPage
  23.             GrpArrayPages(Me.Page) = GrpPage
  24.         End If
  25.     Else
  26.         Me!ctlGrpPages = "Page " & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page)
  27.     End If
  28.     GrpNamePrevious = GrpNameCurrent
  29.  
  30. End Sub
Aug 30 '10 #1
0 1167

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At...
2
by: Will | last post by:
I have a 1 page report which I want to print numerous copies of. The number of copies will be specified by the user. My problem is that I want each report to print the copy number of number of...
1
by: David Horowitz | last post by:
Hi folks. I need to create a report that has a Group Header that pulls certain data from the Detail section. It's something like this: +--Report---------------------------------------- |...
4
by: Hugh O | last post by:
Hi, I have been able to use the following kinds of code to access basic information on the individual controls that would be in any Web page. ?Me.Controls(1).Controls(56).GetType.Name ' ...
3
by: maflatoun | last post by:
Hi, I must be losing my mind why is the following code returning wrong values? var d = new Date(); alert(d); -> Fri Apr 7 09:28:18 EDT 2006 alert("Hour:" + d.getHours()); -> 9...
7
by: arnuld | last post by:
/* C++ Primer - 4/e * * 1st example from section 7.2.2, page 234 * returning 2 values from a function * * STATEMENT: * to find a specific value in a vector and number of times * that...
5
by: prads | last post by:
Hello, the following code doesnot return the corect values to the main function. However it prints the correct values within the function. Also the same when written in C works absolutely fine. Pls...
2
Zwoker
by: Zwoker | last post by:
Hi all, I have what appears to be a simple requirement in an MS Access (2003) report, but I just can't get it to work without it causing problems. I have a table with data I want to report on,...
0
by: Jeremy Jones | last post by:
Ok, right now I have some code that is printing the "page of pages" for individual groups in my report. This code has worked in other reports, so I put it in this report. It is however, not doing...
2
by: francisjohn | last post by:
I am beginner for this MS-Access tool. I want to create PDF/MS-Word file from MS Access report. Whatever contents/values is there in MS-Access report, I need to convert these values to PDF/WORD...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.