2013-04-03 25 views
0

我需要用自定义名称保存PDF文件。该名称应包含报告中的参数/值。如何使用从报告中提取的自定义名称保存访问报告?

我需要生成这样的几个报告,所以我需要一个区别,我猜Member_ID字段将提供。我在网上搜索了很多,但我无法实现它。

,我现在使用的代码如下所示:

Private Sub Create_PDF_Click() 

Dim myPath As String Dim strReportName As String 

DoCmd.OpenReport "Proof_Graphs", acViewPreview 

myPath = "C:\Proofs\" 

strReportName = Proof_Graphs.[MEMBER_ID] + "-" + ".pdf" 

DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath + strReportName, True DoCmd.Close acReport, "Proof_Graphs" 

End Sub 

我收到找不到错误的对象。

回答

0

您可以使用 Reports!ReportName!FieldName 'to access the control box for the value on the report

Private Sub Create_PDF_Click() 
Dim myPath As String Dim strReportName As String 
Dim memberID As String 

DoCmd.OpenReport "Proof_Graphs", acViewPreview 

memberID = Reports!Proof_Graphs.[MEMBER_ID]'to access the field for the value on the report 

myPath = "C:\Proofs\" 

strReportName = memberID + ".pdf" 

DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath + strReportName, True DoCmd.Close acReport, "Proof_Graphs" 

End Sub