H
h2fcell
Hello,
I’m in need of some expert advice with a report issue I’m having.
The report has three sections, a TitleCode Header, Detail, and Page Footer.
The report is run for a given day where there could be 10 different
TitleCodes.
The Detail section contains Text Box bound to a Memo field that can cause it
to continue on another page.
I’m using the below code to number my report pages based on the TitleCode
Header group breakout.
'************ Code Start *************
' This code was originally written by James H Brooks.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' James H Brooks
'
Option Compare Database
Option Explicit
Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer
Private Sub PageFooterSection_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!TitleCode
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 = "Page " & GrpArrayPage(Me.Page) & " of " &
GrpArrayPages(Me.Page)
End If
GrpNamePrevious = GrpNameCurrent
End Sub
'************ Code End *************
The code works correctly producing the following results:
TitleCode
R-2009-1 1 page Footer has - “Page 1 of 1â€
R-2009-2 2 pages Footer has - “Page 1 of 2†on first page and
“Page 2 of 2†on second page.
R-2009-3 1 page Footer has - “Page 1 of 1â€
R-2009-4 3 pages Footer has - “Page 1 of 3†on first page and “Page
2 of 3†on so on.
I would now like to set a labels Visible property in the TitleCode Header to
false on “Pages 1 of #†and then set it back to true on pages <> 1.
I thought the following IF would do the trick but it gives me an error.
Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
If GrpArrayPage(Me.Page) = 1 Then
Me.Label19.Visible = Fales
Else
Me.Label19.Visible = True
End If
End Sub
I don’t think I’m putting the code in the right place.
Any advice would be appreciated.
I’m in need of some expert advice with a report issue I’m having.
The report has three sections, a TitleCode Header, Detail, and Page Footer.
The report is run for a given day where there could be 10 different
TitleCodes.
The Detail section contains Text Box bound to a Memo field that can cause it
to continue on another page.
I’m using the below code to number my report pages based on the TitleCode
Header group breakout.
'************ Code Start *************
' This code was originally written by James H Brooks.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' James H Brooks
'
Option Compare Database
Option Explicit
Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer
Private Sub PageFooterSection_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!TitleCode
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 = "Page " & GrpArrayPage(Me.Page) & " of " &
GrpArrayPages(Me.Page)
End If
GrpNamePrevious = GrpNameCurrent
End Sub
'************ Code End *************
The code works correctly producing the following results:
TitleCode
R-2009-1 1 page Footer has - “Page 1 of 1â€
R-2009-2 2 pages Footer has - “Page 1 of 2†on first page and
“Page 2 of 2†on second page.
R-2009-3 1 page Footer has - “Page 1 of 1â€
R-2009-4 3 pages Footer has - “Page 1 of 3†on first page and “Page
2 of 3†on so on.
I would now like to set a labels Visible property in the TitleCode Header to
false on “Pages 1 of #†and then set it back to true on pages <> 1.
I thought the following IF would do the trick but it gives me an error.
Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
If GrpArrayPage(Me.Page) = 1 Then
Me.Label19.Visible = Fales
Else
Me.Label19.Visible = True
End If
End Sub
I don’t think I’m putting the code in the right place.
Any advice would be appreciated.