[access报表]报表打印如何用代码设定页面-张志
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> Access数据库-报表


[access报表]报表打印如何用代码设定页面

发表时间:2007/10/18 21:39:10 评论(2) 浏览(9872)  评论 | 加入收藏 | 复制
   
摘 要:报表打印如何用代码设定页面
正 文:
报表打印如何用代码设定页面
来源: 爱赛思应用俱乐部

页面设定成横向打印,重新定义打印边距及纸型,如何用代码控制。这是我以前写的自动生成一个多功能的报表的部分代码,我抄在下面,其中包括你说的横向及纵向打印如何用程序设置。

Dim qdf As QueryDef
Dim ctlLabel As Control, ctlText As Control
Dim intDataX As Integer, intDataY As Integer
Dim intLabelX As Integer, intLabelY As Integer
Dim ncnt As Integer
Dim I As Integer
Dim ttlwidth As Double
Dim rptWaste As Report
Me.Painting = False
On Error Resume Next
Dim Dbs As Database, ctr As Container, doc As Document
Set Dbs = CurrentDb
ncnt = 0



Set rptWaste = CreateReport
Dbs.QueryDefs.Delete "www"
Set qdf = Dbs.CreateQueryDef("www", sql)
Dbs.QueryDefs.refresh
ttlwidth = 30
rptWaste.Section(acPageHeader).Height = 800

For I = 1 To 30 - 1
If Not (IsNull(adata(I)) or Trim(adata(I)) = "") Then
Set ctlText = CreateReportControl(rptWaste.name, acTextBox, , "", "", intDataX, intDataY)
Set ctlLabel = CreateReportControl(rptWaste.name, acLabel, acPageHeader, , "NewLabel", intLabelX, intLabelY)
ctlLabel.Caption = adata(I)

ctlText.Width = 1000
If adata(I) = "card_no" Then
ctlText.Width = 1200
ctlLabel.Caption = "卡号"
End If
If adata(I) = "date" Then
ctlText.Width = 1300
ctlLabel.Caption = "日期"
End If
If adata(I) = "op_name" Then
ctlText.Width = 1300
ctlLabel.Caption = "工序号"
End If
If adata(I) = "class_name" Then
ctlText.Width = 1300
ctlLabel.Caption = "产品类型"
End If
If adata(I) = "dept_code" Then
ctlText.Width = 1000
ctlLabel.Caption = "车间代码"

End If
If adata(I) = "totalwaste_qty" Then
ctlText.Width = 1000
ctlLabel.Caption = "废品总重"
End If
' End If
ctlLabel.Width = ctlText.Width
ctlText.ControlSource = adata(I)
ctlText.BorderStyle = 1
ctlLabel.BorderStyle = 1
ctlText.Left = ttlwidth
ctlLabel.Left = ttlwidth
ctlLabel.Top = 800 - ctlLabel.Height
ctlLabel.FontBold = True
ttlwidth = ttlwidth + ctlText.Width
End If
Next I
rptWaste.RecordSource = "www"
rptWaste.Section(acDetail).Height = ctlText.Height
Set ctlLabel = CreateReportControl(rptWaste.name, acLabel, acPageHeader, , "NewLabel", intLabelX, intLabelY)
ctlLabel.Top = 0
ctlLabel.Caption = Trim(txtDepartment.value) & "废品统计报表"
ctlLabel.TextAlign = 2
ctlLabel.FontSize = 16
ctlLabel.FontBold = True
ctlLabel.Width = 4000
ctlLabel.Height = 500
ctlLabel.Left = (rptWaste.Width - ctlLabel.Width) / 2



Const DM_PORTRAIT = 1
Const DM_LANDSCAPE = 2
Dim DevString As str_DEVMODE
Dim DM As type_DEVMODE
Dim strDevModeExtra As String
If Not IsNull(rptWaste.PrtDevMode) Then
strDevModeExtra = rptWaste.PrtDevMode
DevString.RGB = strDevModeExtra
Lset DM = DevString
DM.lngFields = DM.lngFields or DM.intOrientation ' Initialize fields.

'If DM.intOrientation = DM_PORTRAIT Then
DM.intOrientation = DM_LANDSCAPE
'Else
' DM.intOrientation = DM_PORTRAIT
'End If
Lset DevString = DM ' Update property. <

Access软件网交流QQ群(群号:198465573)
 
 相关文章
【Access入门】打印当前页,打印报表当前页,用报表打印当前窗体...  【麥田  2013/9/9】
【Access入门】送货单打印示例  【沧海桑田  2013/9/15】
按选定的行数范围批量打印  【杜威  2013/11/14】
打印指定份数的报表  【大蒜头  2014/12/29】
打印报表不够固定行数补足空白表格方法  【上官  2015/1/10】
多层级BOM排序打印  【上官  2015/1/17】
常见问答
技术分类
相关资源
文章搜索
关于作者

张志

文章分类

文章存档

友情链接