设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1640|回复: 1
打印 上一主题 下一主题

[报表] [推荐]如何设置报表纸边距(ACCESS2000以下版本)

[复制链接]
跳转到指定楼层
1#
发表于 2002-12-5 22:47:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
How to Set Margins Via Code for a Report

You can set the margins for a report via code prior to previewing or printing a report.  The code below should be placed in a general db module and be called first then call the DoCmd.OpenReport Method.  Note that this code works in Access 95 and above. Even though in Access 2002 (Xp) you can access the margin properties directly in design mode rather than using the PrtMip property, this code will also work on that version of Access for compatibility.
'-------------------Module Declarations----------------

Type str_PRTMIP
    RGB As String * 28
End Type

Type type_PRTMIP
    'Typed as longs due to Ansi to Unicode conversion
    xLeftMargin As Long
    yTopMargin As Long
    xRightMargin As Long
    yBottomMargin As Long
    fDataOnly As Long
    xItemSizeWidth As Long
    yItemSizeHeight As Long
    fDefaultSize As Long
    xItemsAcross As Long
    yColumnSpacing As Long
    xRowSpacing As Long
    rItemLayout As Long
    rFastPrinting As Long
    rDataSheetHeadings As Long
End Type
'------------------------Function-----------------------------
Public Function SetReportMarginDefault(strReportName As String, left!, top!, right!, bottom!)
Dim PrtMipString As str_PRTMIP
Dim PM As type_PRTMIP
Dim objRpt As Report
Dim tempPrtMip As String

DoCmd.Echo False
DoCmd.OpenReport strReportName, acDesign
Reports(strReportName).Painting = False
Set objRpt = Reports(strReportName)

PrtMipString.RGB = objRpt.prtmip

LSet PM = PrtMipString
'Use 1440 for US (inches), 567 (rest of the world) (centimeters)
PM.xLeftMargin = left * 1440            
PM.yTopMargin = top * 1440
PM.xRightMargin = right * 1440         
PM.yBottomMargin = bottom * 1440
  
LSet PrtMipString = PM

objRpt.prtmip = PrtMipString.RGB

'Make sure report has the focus
DoCmd.SelectObject acReport, strReportName
'Save the Report
DoCmd.DoMenuItem 7, acFile, 4, , acMenuVer70
  
CloseRpt:
DoCmd.Close acReport, strReportName
DoCmd.Echo True
  'You're done.

End Function


原文:
http://ourworld.compuserve.com/h ... ARptTip.htm#MARGINS

[em26]
[此贴子已经被作者于2002-12-5 14:47:11编辑过]

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2002-12-5 23:11:00 | 只看该作者
最好还是升级
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 23:03 , Processed in 0.079916 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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