Report Numbering

Dona

Registered User.
Local time
Today, 08:40
Joined
Jun 27, 2002
Messages
55
I used the following code. It works; however, one group report has only one page. I want it to say page 1 of 1. I don't know how to write the code and where to put it. It currently says page 1 of .Please help. Thank you.

Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer

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!D_NAME
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.Pages) = GrpPage
End If
Else
Me!ctlgrpPages = " Page " & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page)
End If
GrpNamePrevious = GrpNameCurrent
End Sub

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

End Sub

Private Sub Report_Open(Cancel As Integer)

End Sub
 
Dona,

You might try this

Me!ctlgrpPages = " Page " & GrpArrayPage(Me.Page) & " of " &
Nz(GrpArrayPages(Me.Page), 1)

Wayne
 
I changed the text a little

Me!ctlgrpPages = " Page " & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page) +1

Thank you WayneRyan for fixing this part. Any ideas for the other part?

WayneRyan was able to help solve part of the problem. (He answered my Report post) Unfortunately, a new problem arose.

It doesn't quite work.
Group A has one page that now says Page 1 of 1.

Group 2 has 2 pages that now says Page 1 of 2.
The second page of Group 2 also says page 1 of 2.

Group 3 has 3 pages that now says Page 1 of 2.
The second page of Group 3 says Page 1 of 2.
The third page of Group 3 also says Page 1 of 2.

Rich
bas-bleu fixed the problem. Thank you Rich!

I will attach a sample in a new post.
 
Last edited:
or maybe u could have gone to the menu and selected Insert > Page x of y or something?

Maybe I am getting my wires crossed?
 
No I couldn't because I was grouping by districts within the 60 page report. For example, District A has 2 pages, District B has 1 page, District C has 10 pages. I wanted District A to say page 1 of 2, page 2 of 2. District B page 1 of 1, etc. Before Wayne's reply, the District B report would be page 1 of (blank).

I hope this makes sense.
 
Thank you again Rich
bas-bleu!

Please see attached with codes, etc.

dona
 

Attachments

Here's another take on the code that seems to work as well...



Dim GrpArrayPage As New Collection, GrpArrayPages As New Collection
Dim GrpNameCurrent As String, GrpNamePrevious As String
Dim GrpPages As Integer

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
Dim I As Integer
If Pages = 0 Then
GrpNameCurrent = D_Name
If GrpNameCurrent = GrpNamePrevious Then
GrpPages = GrpArrayPage((Page - 1)) + 1
GrpArrayPage.Add GrpPages
GrpArrayPages.Add GrpPages
For I = Page - ((GrpPages) - 1) To Page - 1
GrpArrayPages.Remove I
GrpArrayPages.Add GrpPages, , , I - 1
Next I
Else
GrpArrayPage.Add 1
GrpArrayPages.Add 1
End If
Else
ctlgrpPages = "Page " & GrpArrayPage(Page) & " of " & GrpArrayPages(Page)
End If
GrpNamePrevious = GrpNameCurrent
End Sub
 

Users who are viewing this thread

Back
Top Bottom