HomeGrowth
Technical User
I've been following the instructions to reset the page number and the toal page count for each group from here
All I changed is the Group Name from [Binder ](yes, the name has the space at the end) to [Country] in the Microsofe example.
But I didn't get the code to count the total page count for each group. Where I should look?
Here are the codes behind my report. Thanks for help.
Option Compare Database
Option Explicit
Dim DB As Database
Dim GrpPages As Recordset
Function GetGrpPages()
' Find the group name.
'ToDo make sure the field name is right
GrpPages.Seek "=", Me.[Binder ]
If Not GrpPages.NoMatch Then
GetGrpPages = GrpPages![PageNumber]
End If
End Function
Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)
' Set page number to 1 when a new group starts.
Page = 1
'MsgBox "Page# " & Page
End Sub
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
' Find the group.
'2008 0424 ToDo make sure the field name is right
GrpPages.Seek "=", Me![Binder ]
If Not GrpPages.NoMatch Then
' The group is already there.
If GrpPages![PageNumber] < Me.Page Then
GrpPages.Edit
GrpPages![PageNumber] = Me.Page
GrpPages.Update
End If
Else
' First page of group, so add it.
GrpPages.AddNew
'Todo make sure the field names are right in bother sides
GrpPages![Binder ] = Me![Binder ]
GrpPages![PageNumber] = 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 [table_CategoryGroupPages];"
DoCmd.SetWarnings True
Set GrpPages = DB.OpenRecordset("table_CategoryGroupPages", DB_OPEN_TABLE)
GrpPages.Index = "PrimaryKey"
End Sub
All I changed is the Group Name from [Binder ](yes, the name has the space at the end) to [Country] in the Microsofe example.
But I didn't get the code to count the total page count for each group. Where I should look?
Here are the codes behind my report. Thanks for help.
Option Compare Database
Option Explicit
Dim DB As Database
Dim GrpPages As Recordset
Function GetGrpPages()
' Find the group name.
'ToDo make sure the field name is right
GrpPages.Seek "=", Me.[Binder ]
If Not GrpPages.NoMatch Then
GetGrpPages = GrpPages![PageNumber]
End If
End Function
Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)
' Set page number to 1 when a new group starts.
Page = 1
'MsgBox "Page# " & Page
End Sub
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
' Find the group.
'2008 0424 ToDo make sure the field name is right
GrpPages.Seek "=", Me![Binder ]
If Not GrpPages.NoMatch Then
' The group is already there.
If GrpPages![PageNumber] < Me.Page Then
GrpPages.Edit
GrpPages![PageNumber] = Me.Page
GrpPages.Update
End If
Else
' First page of group, so add it.
GrpPages.AddNew
'Todo make sure the field names are right in bother sides
GrpPages![Binder ] = Me![Binder ]
GrpPages![PageNumber] = 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 [table_CategoryGroupPages];"
DoCmd.SetWarnings True
Set GrpPages = DB.OpenRecordset("table_CategoryGroupPages", DB_OPEN_TABLE)
GrpPages.Index = "PrimaryKey"
End Sub