[access报表]打印access报告
时 间:2009-08-22 07:05:25
作 者: ID:4070 城市:杭州
摘 要:打印Access报告
正 文:
创建报表的三个实例。
对一个实例号的提示。
打印所选的实例。
创建此示例的步骤
启动 Access。
在 帮助 菜单上指向 示例数据库 ,然后单击 Northwind 示例数据库 。
向报表页眉中添加一个未绑定的文本框。 名称文本框 txtInstance 。
更改文本框的标签标题 实例: 。
在 编辑 菜单中上, 单击 选择报告 。
将以下代码添加到 OnOpen 事件过程:
Me.txtInstance = x
保存,然后关闭报表。
在设计视图中打开模块 启动 。
将下行添加到 Declarations 部分:
Public x As Integer
保存,然后关闭模块。
创建新的窗体。 命名 Form 1 。
将一个命令按钮添加到窗体。 命名 0 。
在 视图 菜单上单击 代码 ,,,然后添加以下代码:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_ACTIVATE = &H6
Private col As VBA.Collection
Private Sub Command0_Click()
'Set x to 1 for the example.
x = 1
'Assumes Alphabetical List of Products HasModule Property = True
Dim r As [Report_Alphabetical List of Products]
Dim intWhichReport As Integer
Dim result As Long
Dim i As Integer
Static Values(3) As Double ' Set up array.
Set col = Nothing
Set col = New VBA.Collection
'Fill the custom collection with 3 instances of the Alphabetical
'List of Products report, and make them all visible.
For i = 1 To 3
Set r = New [Report_Alphabetical List of Products]
r.Visible = True
'Add 1 to x.
'Report open event will use new value.
x = x + 1
col.Add r
'Store the handle in the array.
Values(i) = col.Item(i).hwnd
Next
'Ask the user for which instance (1 to 3) of the report to print.
On Error Resume Next
intWhichReport = InputBox("Which report instance (1-3) do you want to print?")
'Get the number entered by the user, and grab the appropriate instance
'from the custom collection. Then get its hWnd property and pass it to
'the SendMessage function, so that the proper report instance becomes
'the active report. Then use DoCmd.PrintOut to print that instance.
If Err.Number = 0 Then
result = SendMessage(Values(intWhichReport), WM_ACTIVATE, True, True)
DoCmd.PrintOut
End If
End Sub
在窗体视图中打开 Form 1 窗体,然后单击 0 。 键入要打印的实例的数量,然后单击 确定 。
请注意在打印的报表在报表页眉中实例数量的与您选择的实例。
Access软件网QQ交流群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 合并列数据到一个文本框的示例;...(05.06)
- 通过命令按钮让Access列表...(04.24)
- 统计当月之前(不含当月)的记录...(03.11)
- 【Access Inputbo...(03.03)
- 按回车键后光标移动到下一条记录...(02.12)
- 【Access Dsum示例】...(02.07)
- Access对子窗体的数据进行...(02.05)
- 【Access高效办公】上月累...(01.09)
- 【Access高效办公】上月累...(01.06)

学习心得
最新文章
- 仓库管理实战课程(18)-设置日期...(05.19)
- 仓库管理实战课程(17)-库存明细...(05.13)
- 【Access高效办公】条件格式设...(05.12)
- 仓库管理实战课程(16)-联合查询...(05.07)
- 合并列数据到一个文本框的示例;输出...(05.06)
- 仓库管理实战课程(15)-月度库存...(04.30)
- Access选择打印机、横纵向、纸...(04.29)
- 仓库管理实战课程(14)-出库功能...(04.26)
- 通过命令按钮让Access列表框指...(04.24)
- 仓库管理实战课程(13)-入库功能...(04.21)