设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

[高6]在Access的MDE中如何用VBA自定义纸张

[复制链接]
1#
发表于 2007-6-11 23:51:00 | 显示全部楼层
以下是引用guoya在2006-4-16 18:45:00的发言:


在xp系统中利用print对象可以实现,转换为mde后使用正常

首先将页面边距和自定义纸张设置为两个表,

在模块中编写代码

Public Sub PrintMargin(r As Report)
Dim intTop As Integer '上边距
Dim intLeft As Integer '左边距
Dim intBottom As Integer '下边距
Dim intRight As Integer '右边距
Dim strPrtname As String '报表名称
Dim intpapersize As Integer '纸张大小
Dim intorientation As Integer '打印方向
strPrtname = r.name
intTop = DLookup("[RPTTOP]", "页面", "[RPTNAME]='" & strPrtname & "'") * 567
intBottom = DLookup("[RPTBOT]", "页面", "[RPTNAME]='" & strPrtname & "'") * 567
intLeft = DLookup("[RPTLEFT]", "页面", "[RPTNAME]='" & strPrtname & "'") * 567
intRight = DLookup("[RPTRIGHT]", "页面", "[RPTNAME]='" & strPrtname & "'") * 567
intpapersize = DLookup("[papersize]", "页面", "[RPTNAME]='" & strPrtname & "'")
intorientation = DLookup("[Orientation]", "页面", "[RPTNAME]='" & strPrtname & "'")
r.Printer.PaperSize = intpapersize
r.Printer.Orientation = intorientation
r.Printer.TopMargin = intTop
r.Printer.BottomMargin = intBottom
r.Printer.LeftMargin = intLeft
r.Printer.RightMargin = intRight
End Sub

Public Sub SavePM(r As Report)
Dim RS As DAO.Recordset
Dim strPrtname As String
strPrtname = r.name
Set RS = CurrentDb.OpenRecordset("SELECT * FROM 页面 WHERE rptName='" & strPrtname & "'")
RS.Edit
RS("rpttop") = r.Printer.TopMargin / 567
RS("rptbot") = r.Printer.BottomMargin / 567
RS("rptleft") = r.Printer.LeftMargin / 567
RS("rptright") = r.Printer.RightMargin / 567
RS("papersize") = r.Printer.PaperSize
RS("Orientation") = r.Printer.Orientation
RS.Update
End Sub

在报表的close事件中调用Call SavePM(Reports(Me.name))

在报表打开前Call PrintMargin(Reports("报表名称"))

为何要在报表预览的“页面设置”调用后要按"确定"才能改变?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-6-9 22:42 , Processed in 0.079371 second(s), 23 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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