【发布时间】:2020-09-21 01:09:18
【问题描述】:
帮帮我,我编写的这段代码创建了多个文件,但每个文件只包含第一条记录中的值: 我想要表格中每条记录的文件 pdf。
Option Compare Database
Option Explicit
Private Declare PtrSafe Sub
Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
Private Sub Creazione_Click()
Dim rs As DAO.Recordset
Dim rpt As Access.Report
Dim sFolder As String
Dim sFile As String
Const sReportName = "Mandato"
sFolder = "C:\Users\Famiglia\Desktop\Mandati\"
Set rs = Me.RecordsetClone
With rs
If .RecordCount <> 0 Then
'Open the Report
DoCmd.OpenReport sReportName, acViewPreview, , , acHidden
'Define a report object so we can manipulate it below
Set rpt = Reports(sReportName).Report
.MoveFirst
Do While Not .EOF
'Build the PDF filename we are going to use to save the PDF with
sFile = Nz(![id], "") & " " & Nz(![COGNOME], "") & ".pdf"
sFile = sFolder & sFile
DoCmd.OutputTo acOutputReport, sReportName, acFormatPDF, sFile, , , , acExportQualityPrint
Call Sleep(1000)
DoEvents
.MoveNext
Loop
DoCmd.Close acReport, sReportName
End If
End With
End Sub
【问题讨论】:
标签: ms-access pdf printing report