设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

123
返回列表 发新帖
楼主: wuaza
打印 上一主题 下一主题

[报表] 如何在报表的组页脚显示“第x页,共y页”?

[复制链接]
21#
发表于 2006-4-2 07:38:00 | 只看该作者
henhao
22#
发表于 2006-4-4 01:26:00 | 只看该作者
还是不知道在哪?我例子里哪里有Text111
23#
发表于 2006-4-4 01:33:00 | 只看该作者
以下是引用winner在2006-3-30 15:51:00的发言:


我只改了红色部分:

Option Compare Database
Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer
Private Sub 页面页脚_Format(Cancel As Integer, FormatCount As Integer)
1001 Dim I As Integer
1002 If Me.Pages = 0 Then   '准备资料时计算各群组页数
1003    ReDim Preserve GrpArrayPage(Me.Page + 1)
1004    ReDim Preserve GrpArrayPages(Me.Page + 1)
1005    GrpNameCurrent = Me![WareHouse]    '取得现用群组字段之值
1006    If GrpNameCurrent = GrpNamePrevious Then '如果现用群组大于1页
1007        GrpArrayPage(Me.Page) = GrpArrayPage(Me.Page - 1) + 1
1008        GrpPages = GrpArrayPage(Me.Page)
1009        For I = Me.Page - ((GrpPages) - 1) To Me.Page
1010            GrpArrayPages(I) = GrpPages
1011        Next I
1012    Else                             '如果现用群组只有1页
1013        GrpPage = 1
1014        GrpArrayPage(Me.Page) = GrpPage
1015        GrpArrayPages(Me.Page) = GrpPage
1016    End If
1017 Else              '打印
1018     Me![PageNo].Caption = "  第 " & GrpArrayPage(Me.Page) & " 页,共 " & GrpArrayPages(Me.Page) & " 页"
1019 End If
1020 GrpNamePrevious = GrpNameCurrent

End Sub
Private Sub Report_Page()
GrpPage = 0
GrpPages = 0
GrpNameCurrent = ""
GrpNamePrevious = ""
End Sub

代码左侧有编号,这个编号是一个个手工加上去的吗?还是有什么设置?有编号会不会影响代码运行?要怎么设才能跟你的一样有代码?
24#
 楼主| 发表于 2006-4-4 20:26:00 | 只看该作者
以下是引用winner在2006-4-3 17:26:00的发言:


还是不知道在哪?我例子里哪里有Text111



你例子里有个text21,你看看它的控件来源。

其实这个报表的设计除了vba 代码外,必须在报表里加入一个包含pages表达式的控件,有了pages,格式化事件就会先遍历全部页,以统计总页数, If Me.Pages = 0 Then  这一句才能得到多次调用。

这是关键。

这个示例中的数组技巧很值得学习!

[此贴子已经被作者于2006-4-4 12:26:36编辑过]

25#
发表于 2006-4-4 21:34:00 | 只看该作者
谢谢!我看到了,原来text21在页眉缩到小小的.厉害!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-9-30 04:41 , Processed in 0.156152 second(s), 27 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表