你先把每页固定5行的功能做好,才有可能实现分组报表每个组的第几页共几页。我以前发过一个分组报表实现分组第几页共几页的实例,论坛改版后找不到这个帖子了。
源码如下:
Dim GPage(), GPages()
Dim GNameCurrent As Variant, GNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer
Private Sub 页面页脚_Format(Cancel As Integer, FormatCount As Integer)
Dim I As Integer
If Me.Pages = 0 Then '计算各分组页数
ReDim Preserve GPage(Me.Page + 1)
ReDim Preserve GPages(Me.Page + 1)
GNameCurrent = Me![分组字段名] '取得分组值
If GNameCurrent = GNamePrevious Then '如果分组大于1页
GPage(Me.Page) = GPage(Me.Page - 1) + 1
GrpPages = GPage(Me.Page)
For I = Me.Page - ((GrpPages) - 1) To Me.Page
GPages(I) = GrpPages
Next I
Else '如果分组只有1页
GrpPage = 1
GPage(Me.Page) = GrpPage
GPages(Me.Page) = GrpPage
End If
Else '打印
Me![组页码].Caption = " 第" & _
GPage(Me.Page) & "页,共" & GPages(Me.Page) & "页"
End If
GNamePrevious = GNameCurrent
End Sub
Private Sub Report_Page()
GrpPage = 0
GrpPages = 0
GNameCurrent = ""
GNamePrevious = ""
End Sub