Access 2013:使用报表仅将表单的当前记录发送到 PDF



我有一个表单,用户可以在其中输入所有数据。有一个"保存"按钮,用于保存记录,并使表单处于活动状态。在关闭表单之前,我需要获取新保存的记录,并将关联的报告输出到PDF文件中。我现在的问题是PFD的输出是发送表中的所有记录,而不仅仅是表单中的记录。这是我目前的代码。

Private Sub cmdSave_Click()
Dim outl As Outlook.Application
Dim mi As Outlook.MailItem
Dim strWhere As String
Cause = "SaveButton"
DoCmd.RunCommand acCmdSaveRecord
'Save the Record
Me.btnClose.SetFocus
If Me.DateOfVisit <> "" Then
Me.RepStatus = "Report Saved!"
Me.btnNewReport.Visible = True
'Now, print the report to a PDF File
DoCmd.OutputTo acOutputReport, "rptReports", acFormatPDF,"C:ReportTest.pdf", False
End If
End Sub

顺便说一句,要求用户不会看到屏幕上弹出的报告,然后迅速消失。

感谢您的帮助。

看起来我终于把它套住了。我添加了以下行,现在它正在工作。事实证明OutputTo没有办法传入任何搜索条件。所以,我在隐藏模式下打开了报告,这样用户就看不到任何东西,然后使用OutputTo将其发送到PDF。

'Now, print the report to a PDF File
DoCmd.OpenReport "rptReports", acViewReport, , "[ReportID] = " & [ReportID], acHidden
DoCmd.OutputTo acOutputReport, "rptReports", acFormatPDF, "C:TG QUOTE SYSTEMMeeting ReportsReportTest.pdf", False
DoCmd.Close acReport, "rptReports"

如果结束

谢谢大家。

最新更新