我一直在Access数据库中工作。我有一份大约500页的报告,按[event_musician.name]排序。我想将每个名称的报告保存为pdf,而不是必须在PDF编辑器中从完整的500页中提取每个迷你报告。这是我尝试过的循环。
Dim ProviderNm As String
Dim PathNm As String
Dim RptNm As String
Dim strFileNm As String
Dim Sql As String
Dim db As Database
Dim rs As Recordset
strPathNm = "C:\RVU\"
strRptNm = "all_performer_schedule"
Sql = "SELECT event_musician_details.name FROM (event INNER JOIN event_musician_details ON event.job_number = event_musician_details.job_number) INNER JOIN musicians ON event_musician_details.name = musicians.name WHERE (((event.Date)>Now()))"
Set db = CurrentDb
Set rs = db.OpenRecordset(Sql)
Do Until rs.EOF
ProviderNm = rs!name
strFileNm = strPathNm & ProviderNm & ".pdf"
DoCmd.OpenReport strRptNm, acViewPreview, ProviderNm
DoCmd.OutputTo acOutputReport, strRptNm, acFormatPDF, strFileNm
DoCmd.Close acReport, strRptNm
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
它成功地在每个人的名字下保存了一个pdf,但它一遍又一遍地保存整个500页文件,而不仅仅是基于个人名字的页面。有什么想法吗?