设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

[报表] 简单的固定每页行数报表制作示例分页报表

[复制链接]
跳转到指定楼层
1#
发表于 2006-9-22 02:28:00 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
我在本论坛搜索了有关话题,但是很多例子都看不明白。后来我自己做了一个,超简单!

游客,如果您要查看本帖隐藏内容请回复



特别感谢andymark,没有他,这个程序就行不通了。

'说明:必须在报表主体增加一个分页符(在工具箱),分页符名为:ageBreak9.

全部代码如下:

Option Compare Database
Dim aaa As Long ' 行数变量

'下面代码提示输入行数

rivate Sub Report_Open(Cancel As Integer)
aaa = InputBox("请输入固定的行数[试用建议1-6]", "请输入行数", 3)
End Sub

'下面代码实现分页

rivate Sub 主体_Format(Cancel As Integer, FormatCount As Integer)
If Me.counter Mod aaa = 0 Then '每隔aaa行分页
Me.PageBreak9.Visible = True
Else
Me.PageBreak9.Visible = False
End If

End Sub

'下面代码自动给表格加边框并换行

;Private Sub 主体_Print(Cancel As Integer, PrintCount As Integer)
Dim CtlDetail As Control
Dim intLineMargin As Integer

intLineMargin = 60

For Each CtlDetail In Me.Section(acDetail).Controls
    With CtlDetail
      If CtlDetail.ControlType <> acPageBreak Then
        If CtlDetail.Name <> "Memo" Then
        Me.Line ((.Left + .Width + intLineMargin), 1)-(.Left + .Width + _
intLineMargin, Me.Height)
        End If
        End If
    End With
   
Next
   

    With Me
        Me.Line (1, 1)-Step(.Width, .Height), 1, B
    End With

Set CtlDetail = Nothing
End Sub


[此贴子已经被作者于2006-11-22 19:03:06编辑过]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
 楼主| 发表于 2006-11-23 02:56:00 | 显示全部楼层
代码如下(有更改):

Option Compare Database
Dim aaa As Long '行数

Private Sub Report_Open(Cancel As Integer)
aaa = InputBox("请输入固定的行数[试用建议1-6]", "请输入行数", 3)
End Sub

Private Sub 主体_Format(Cancel As Integer, FormatCount As Integer)
If Me.counter Mod aaa = 0 Then '每隔aaa行分页
Me.PageBreak9.Visible = True
Else
Me.PageBreak9.Visible = False
End If

End Sub

Private Sub 主体_Print(Cancel As Integer, PrintCount As Integer)
Dim CtlDetail As Control
Dim intLineMargin As Integer

intLineMargin = 60

For Each CtlDetail In Me.Section(acDetail).Controls
    With CtlDetail
      If CtlDetail.ControlType <> acPageBreak Then
        If CtlDetail.Name <> "Memo" Then
        Me.Line ((.Left + .Width + intLineMargin), 1)-(.Left + .Width + _
intLineMargin, Me.Height)
        End If
        End If
    End With
   
Next
   

    With Me
        Me.Line (1, 1)-Step(.Width, .Height), 1, B
    End With

Set CtlDetail = Nothing
End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-8 04:04 , Processed in 0.084583 second(s), 27 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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