Puzzled...why isn't the Of # showing up?

MarcieFess

Registered User.
Local time
Today, 15:12
Joined
Oct 25, 2012
Messages
107
Hi. I hae gotten such wonderful help here...many thanks to you all, especially Cheryl!

I've used a report that Cheryl did for me as a foundation for another report, this time with the page numbers in the footer. It's another "group by" situation, with page numbers beginning at 1 for each group. That's working fine.

My issue is that the "of ##" is showing blank.

Here's my code:

Dim DB As Database
Dim GrpPages As Recordset
Function GetGrpPages()
'Find the group name.
GrpPages.Seek "=", Me![Hazard Class]
If Not GrpPages.NoMatch Then
GetGrpPages = GrpPages![Page Number]
End If

End Function
Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
'Set page number to 1 when a new group starts.
Page = 1
End Sub
Private Sub Report_Open(Cancel As Integer)
Set DB = DBEngine.Workspaces(0).Databases(0)
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * From ztblHazardClass;"
DoCmd.SetWarnings True
Set GrpPages = DB.OpenRecordset("ztblHazardClass", DB_OPEN_TABLE)
GrpPages.Index = "PrimaryKey"

End Sub
Private Sub PageFooter_Format(Cancel As Integer, FormatCount As Integer)
'Find the group.
GrpPages.Seek "=", Me![Hazard Class]

If Not GrpPages.NoMatch Then
'The group is already there.
If GrpPages![Page Number] < Me.Page Then
GrpPages.Edit
GrpPages![Page Number] = Me.Page
GrpPages.Update
End If
Else
'This is the first page of the group. Therefore, add it.
GrpPages.AddNew
GrpPages![Hazard Class] = Me![Hazard Class]
GrpPages![Page Number] = Me.Page
GrpPages.Update
End If
End Sub


I think this is working fine...the page numbering starts over at 1 for each Hazard Class, etc.

However...the table 'ztblHazardClass' that I set up with fields Hazard Class and Page Number is not populated after running the report...is this an issue?

I've created 2 text box controls (invisible) in the Page Footer. The first one is named GroupXY and the control source is =GetGrpPages()

The second one is named ReferToPages and the control source is =[Pages]

The control for printing the page numbers is named Page Number Box and the control source is =[Hazard Class] & " - Page " & [Page] & " of " & [GroupXY]

I fell like I've missed something in writing the code, but I'm not sure what, since the table is empty.

As always, help is greatly appreciated.

Everyone have a happy Thanksgiving!
 
Just wanted to let everyone know that this issue is solved...I moved the code from PageFooter to PageFooterSection and it works beautifully. Just in case someone else has a similar issue and wants to use this solution!
 

Users who are viewing this thread

Back
Top Bottom