【发布时间】:2026-01-14 17:05:02
【问题描述】:
我正在 Access 2007 中创建一个报告,并且能够将其保存为 PDF,但问题是每个 PDF 没有 1 个报告,我在 1 个 PDF 中有 206 个报告。我正在使用 VBA 以编程方式执行此操作 这是我正在使用的代码
Sub makeLetterPDF(Contract As String, LetterType, outTo As String)
Dim rs As New ADODB.Recordset
Dim strReportName As String
Dim strFileName As String
Dim Maxrow As Integer
Dim C As Integer
Dim fileno As Integer
SysCmd acSysCmdSetStatus, "Saving " & C & " of " & Maxrow
strReportName = LetterType
strFileName = LetterType & fileno & ".PDF"
fileno = fileno + 1
DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, _
outTo & "\" & strFileName, , , , acExportQualityPrint ``"
SysCmd acSysCmdSetStatus, " "
End Sub
Private Sub Report_Open(Cancel As Integer)
Dim strRecordSource As String
strRecordSource = "Exec dbo.rsp_Letter_ServiceBooking '" & Contract & "'"
Me.RecordSource = strRecordSource
End Sub
打开的报告具有存储过程,其中包含报告所需的数据,但是当makeLetterPDF 首先运行时,我如何遍历它以创建单独的报告
【问题讨论】: