Grouped report adding blank page at the end of the report

MarcieFess

Registered User.
Local time
Today, 06:20
Joined
Oct 25, 2012
Messages
107
Hello all! I thought I was done with this project...just a few housekeeping things.

I have a report that is grouped by Hazard Class. Each class begins on a new page.

I have it numbering pages "Page n of nn" in the footer, and it's working fine...except for the last hazard class. It's throwing in a blank page and including it in the page count for that last hazard class.

It's not because the hazard class is too long...this particular store, there's only 1 item in that last hazard class.

Any ideas?

Here's the code for the report:

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_NoData(Cancel As Integer)
Cancel = True

End Sub
Private Sub PageFooterSection_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

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)

End Sub
 

Users who are viewing this thread

Back
Top Bottom