SECOND REQUEST - Reset Page Numbers by Group

B

Bev

I cannot get this code to work. Every page has 1 of 1 on
it. Any suggestions?

CODE:
Dim DB As DAO.Database
Dim GrpPages As DAO.Recordset
Private Sub GroupHeader0_Format(Cancel As Integer,
FormatCount As Integer)
'Set page number to 1 when a new group starts.
Page = 1
End Sub
Function GetGrpPages()
'Find the group name.
GrpPages.Seek "=", Me![Prescriber]
If Not GrpPages.NoMatch Then
GetGrpPages = GrpPages![Page Number]
End If
End Function
Private Sub Report_Open(Cancel As Integer)
Set DB = DBEngine.workspaces(0).databases(0)
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * From [Category Group Pages];"
DoCmd.SetWarnings True
Set GrpPages = DB.OpenRecordset("Category Group
Pages", DB_OPEN_TABLE)
GrpPages.Index = "PrimaryKey"
End Sub
Private Sub PageFooter_Format(Cancel As Integer,
FormatCount As Integer)
'Find the group.
GrpPages.Seek "=", Me![Prescriber]
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![Prescriber] = Me![Prescriber]
GrpPages![Page Number] = Me.Page
GrpPages.Update
End If

End Sub
 
M

Mike D

Change this line:
Private Sub PageFooter_Format(Cancel As Integer,
FormatCount As Integer)

to this line
Private Sub PageFooterSection_Format(Cancel As Integer,
FormatCount As Integer)

by adding "section" after PageFooter. That is one step forward. I am trying to figure out the rest in this discussion group.

Mike

Bev said:
I cannot get this code to work. Every page has 1 of 1 on
it. Any suggestions?

CODE:
Dim DB As DAO.Database
Dim GrpPages As DAO.Recordset
Private Sub GroupHeader0_Format(Cancel As Integer,
FormatCount As Integer)
'Set page number to 1 when a new group starts.
Page = 1
End Sub
Function GetGrpPages()
'Find the group name.
GrpPages.Seek "=", Me![Prescriber]
If Not GrpPages.NoMatch Then
GetGrpPages = GrpPages![Page Number]
End If
End Function
Private Sub Report_Open(Cancel As Integer)
Set DB = DBEngine.workspaces(0).databases(0)
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * From [Category Group Pages];"
DoCmd.SetWarnings True
Set GrpPages = DB.OpenRecordset("Category Group
Pages", DB_OPEN_TABLE)
GrpPages.Index = "PrimaryKey"
End Sub
Private Sub PageFooter_Format(Cancel As Integer,
FormatCount As Integer)
'Find the group.
GrpPages.Seek "=", Me![Prescriber]
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![Prescriber] = Me![Prescriber]
GrpPages![Page Number] = Me.Page
GrpPages.Update
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top