2013-04-03 23 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