|
以下是引用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("报表名称"))
为何要在报表预览的“页面设置”调用后要按"确定"才能改变? |
|