Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-报表

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

时 间:2007-10-18 21:39:10
作 者:竹笛   ID:8  城市:上海  QQ:2851379730点击这里给张志发消息
摘 要:报表打印如何用代码设定页面
正 文:

报表打印如何用代码设定页面
来源: 爱赛思应用俱乐部

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

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群 (群号:54525238)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助