报告创建与 Web 输出的编程实现
在数据处理和展示的过程中,创建报告和将数据以 Web 格式输出是常见的需求。下面将详细介绍如何通过编程的方式创建报告,以及如何将 Access 数据导出为不同的 Web 格式。
1. 使用 SQL 语句创建 ADO 记录集并关联报告
可以使用 SQL 语句创建 ADO 记录集,并将报告的 RecordSource 属性设置为记录集的 Source 属性。示例代码如下:
'declare and instantiate a new recordset
Dim rsDiscontinued As ADODB.Recordset
Set rsDiscontinued = New ADODB.Recordset
'open the recordset based on the SQL statement
rsDiscontinued.Open strSQL, CurrentProject.Connection
'access the report's design (hidden from the user)
DoCmd.Echo False
DoCmd.OpenReport "Alphabetical List of Products", acViewDesign
'set the source of the report to the recordset source
Reports("Alphabetical List of Products").RecordSource = rsDiscontinued.Source
'close
超级会员免费看
订阅专栏 解锁全文
168万+

被折叠的 条评论
为什么被折叠?



