[access报表]如何使用 VisualBasic 代码来排序和要打印两报告
时 间:2008-08-20 23:15:50
作 者:umvsoft整理 ID:43 城市:江阴
摘 要:如何使用 VisualBasic 代码来排序和要打印两报告
正 文:
本文适用于 MicrosoftAccess 数据库 (.mdb 或 .accdb) 以及在 MicrosoftAccess 项目 (.adp)。
moderate: 要求基本宏、 编码, 和互操作技能。
有关 Microsoft Access 2000 版本与本文, 请参阅 231805 (http://support.microsoft.com/kb/231805/EN-US/).
概要
本文介绍方法, 可用于排序和打印两报告。 此方法备用 DoCmd.SelectObject 和 DoCmd.PrintOut Visual Basic 方法之间两报告。 Microsoft 提供编程示例仅, 供图示不附带任何明示或暗示。 这包括, 但不仅限于, 适销性或用于特定目的适用性的暗示保证。 本文假定您已熟悉与正在演示编程语言以及工具来调试过程来创建和使用。 Microsoft 支持工程师可以帮助解释功能的特定过程, 但它们将会修改这些示例以提供添加功能或构建过程以满足特定要求。
回到顶端
更多信息
有时, 可能要打印某个报表的页 1 和然后 Collate 该页与其他报表的页 1。 打开报告和分别打印每页需要基础查询以每次运行。 一个替代方法是, 采用主 / 子报表中两个报表。
要排序并打印两报告并以测试结果, 请按照下列步骤:
1. 打开示例数据库 Northwind.mdb 或示例 Access 项目 NorthwindCS.adp。
2. 创建一个新模块, 然后键入或粘贴以下代码:
'***********************************
'Declarations section of the module
'***********************************
Option Explicit
'*********************************************************************
'NumPages is the number of pages in the largest report. If one report
'has fewer pages, the DoCmd.PrintOut statement for the smaller report
'runs correctly, and no additional pages are printed.
'*********************************************************************
Function CollateReports(NumPages, Rpt1 As String, Rpt2 As String)
Dim MyPageNum As Integer
'Set the page number loop and alternate printing the report pages.
For MyPageNum = 1 To NumPages
'NumPages is the number of pages to print.
DoCmd.SelectObject acReport, Rpt1, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
DoCmd.SelectObject acReport, Rpt2, True
DoCmd.PrintOut acPages, MyPageNum, MyPageNum
Next MyPageNum
End Function
3. 要测试结果, 立即窗口中键入以下行, 然后按 ENTER 键:
? CollateReports(1, "Sales by Category", "Sales Totals by Amount")
注意 MicrosoftAccess 从每个报表打印一页。
Access软件网QQ交流群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access选项卡示例】Ac...(09.09)
- 【Access源码示例】按输入...(09.02)
- 【Access日期区间段查询】...(08.29)
- 【Access日期区间段查询】...(08.27)
- Access怎样才能实现日期时...(08.21)
- 【Access定时打开查询】A...(08.19)
- Access生成固定数量的记录...(08.13)
- Access怎样才能实现日期时...(08.12)
- Access利用导航窗体控件对...(08.03)
学习心得
最新文章
- Access自定义函数命名为中文名...(09.20)
- Access表中的字段名、字段标题...(09.19)
- Access快速开发平台--更改“...(09.18)
- 【中秋及国庆优惠】Access培训...(09.15)
- Access如何将日期型的数值转换...(09.14)
- 英文输入法输入数据中存在单引号引起...(09.11)
- 【Access选项卡示例】Acce...(09.09)
- 让Access光标停留在指定的控件...(09.07)
- 关于Access查询条件里使用通配...(09.06)
- Access报表偷懒制作法--Ac...(09.05)