Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set page number by group??? 4

Status
Not open for further replies.

jlitondo

MIS
Jun 27, 2000
175
US
I have a report that is grouped by customer, that is, it prints several customers with their specific contract information.I have each new customer begin on a fresh page but the contract info can spill over to several pages.How do I reset the page numbers for each customer grouping?Any pointers will be appreciated.
 
Hi,

I still get an error saying "Subscript out of range" !!? THE error seems to be coming from the 3rd to last line of code (is has changed to yellow) that reads:

Me!ctlGrpPages = "Group Page " & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page)
Hints:
1)The controltip changes to the message :
&quot;GrpArraypage(Me.Page)=<subscript out of range>&quot; when i move it over the words &quot;GrgArrayPage&quot; in the 3rd tl last line of code

2)The control tip shows that the value of (Me.Pages) as &quot;Me.Page=1&quot;

ZaZa
 
This is the exact syntax that works for me. Change GrpNameCurrent = Me!RuleName to your name.....

Code:
Option Compare Database
Option Explicit
Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer


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

End Sub

Private Sub PageFooter_Format(Cancel As Integer, FormatCount As Integer)
Dim i As Integer
  If Me.Pages = 0 Then
    ReDim Preserve GrpArrayPage(Me.Page + 1)
    ReDim Preserve GrpArrayPages(Me.Page + 1)
    GrpNameCurrent = Me!RuleName
    If GrpNameCurrent = GrpNamePrevious Then
        GrpArrayPage(Me.Page) = GrpArrayPage(Me.Page - 1) + 1
        GrpPages = GrpArrayPage(Me.Page)
            For i = Me.Page - ((GrpPages) - 1) To Me.Page
                GrpArrayPages(i) = GrpPages
            Next i
    Else
        GrpPage = 1
        GrpArrayPage(Me.Page) = GrpPage
        GrpArrayPages(Me.Page) = GrpPage
    End If
  Else
    Me!ctlGrpPages = &quot;Group Page &quot; & GrpArrayPage(Me.Page) & &quot; of &quot; & GrpArrayPages(Me.Page)
  End If
  GrpNamePrevious = GrpNameCurrent

End Sub
 
Thanks CosmoKramer!!!!!!!!!!!!!!

I had the first Dim statements in the Private Sub Function area and not in the declaration section where they should have been.

I realised this when I deleted all the code written thus far and pasted everything in the declarations section. Access automatically arranged the rest in the relevent Sub procedure.


Thanks a lot for your patience and time.

Now I will just sit here and stare at the screen saver until it's time to leave as I feel quite incapable of thinking (or not thinking- which ever-way you look at it) anymore for the rest of the day.

thanks again,
ZaZa
 
I've been staring at this problem for several days now and am so glad to have found this thread, but I am still having a problem. The code shows the correct number of pages, but I'm not getting it to show in the area of the unbound text box on the footer of the report. What am I missing?

I guess I'm confused as to where this goes... me!ctlgrppages = &quot;Group Page &quot; & GrpArrayPage(Me.Page) & &quot; of &quot; & GrpArrayPages(Me.Page)...in the footer information.

Thanks
 
I too was very perplexed by the code that was posted by James H Brooks. I first had to change &quot;Private Sub PageFooter_Format&quot; to &quot;Private Sub PageFooterSection_Format&quot; because that is the naming convention that my program was using. Second, I had to go to the Insert menu and add Page Numbers...&quot;N of M&quot; field in my page footer and set its Visible property to &quot;No&quot;. I realized that the code only worked if [Pages] was included somewhere in the report. Without this invisible text box, my Report was not formatting twice and nothing was showing in my ctlGrpPages.
 
Hi all-
I was very happy to find this thread and I had almost all the problems that you all had. The one important thing that this article didnot mention was what &quot;Ilovemyjob&quot; stated. This ist the statement:

I had to go to the Insert menu and add Page Numbers...&quot;N of M&quot; field in my page footer and set its Visible property to &quot;No&quot;. I realized that the code only worked if [Pages] was included somewhere in the report. Without this invisible text box, my Report was not formatting twice and nothing was showing in my ctlGrpPages.

With out this bit of info I could see why I and everyone else couldn't get it to work. I hope this helps
 
Okay, I have tried everything that everyone has suggested and I am still having problems. Instead of getting Page 1 of 4 or Page 3 of 4, I am getting Page 2 of 2, Page 3 of 3, and Page 4 of 4. Any suggestions on where my problem may be? The only place that something could be wrong is where I changed Me!Salesperson to my group name control. The group by which I need to restart my page numbers is called Work Area and I typed it in on the code as [Work Area] because that is the only way the code would work properly. Could this be where my problem is? I would appreciate any help on this matter because I am becoming extremely frustrated.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top