export pdf with field names included with file name

jgabel

Registered User.
Local time
Today, 08:39
Joined
Mar 29, 2012
Messages
42
Okay, this is way beyond my expertise, I do not know visual basic at all, I'm really guessing with what I have below. I can run macro's, reports and queries, but not visual basic.

I have a report that I would like to export to a folder, and I would like to include the FullName within the naming convention of the PDF. When I run the report it prompts for the Employee ID

Here is what I have so far, I'm getting an error of "Run Time Error 424 object required" on the String Report Name, what am i doing wrong?

Private Sub Create_PDF_Click()
Dim myPath As String
Dim strReportName As String
DoCmd.OpenReport "Report_Salary_Worksheet _Finalized_By_EmpID", acViewPreview
myPath = "W:\COMPENS\PHYSICIANS\Comp Plans\"
strReportName = Report_Salary_Worksheet_Finalized_By_EmpID.[FullName] + ".pdf"
DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath + strReportName, True
DoCmd.Close acReport, " Report_Salary_Worksheet _Finalized_By_EmpID "
End Sub
 
Try

strReportName = Reports!Report_Salary_Worksheet_Finalized_By_EmpID.[FullName] & ".pdf"
 
Paul, thank you so much for your reply.

I'm getting a different error, run time error 2103 on the DoCmd indicates report name does not exist in Property Sheet or macro is misspelled or referes to a report that does not exist

Private Sub Create_PDF_Click()
Dim myPath As String
Dim strReportName As String
DoCmd.OpenReport "Report_Salary_Worksheet_Finalized_By_EmpID", acViewPreview
myPath = "W:\COMPENS\PHYSICIANS\Comp Plans\"
strReportName = Reports!Report_Salary_Worksheet_Finalized_By_EmpID.[FullName] & ".pdf"
DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath + strReportName, True
DoCmd.Close acReport, " Report_Salary_Worksheet _Finalized_By_EmpID "
End Sub
 
You haven't included the report name in the OutputTo line.
 
That might help, I have never done visual basic this way, so appreciate your patience with me.

I added the report name to the Output Line, but I'm still getting error 2451, this time on the Str report line

Sorry, but this is way beyond my knowledge base

Private Sub Create_PDF_Click()
Dim myPath As String
Dim strReportName As String
DoCmd.OpenReport "Report_Salary_Worksheet _Finalized_By_EmpID", acViewPreview
myPath = "W:\COMPENS\PHYSICIANS\Comp Plans\"
strReportName = Reports!Report_Salary_Worksheet_Finalized_By_EmpID.[FullName] & ".pdf"
DoCmd.OutputTo acOutputReport, "Report_Salary_Worksheet _Finalized_By_EmpID", acFormatPDF, myPath + strReportName, True
DoCmd.Close acReport, " Report_Salary_Worksheet _Finalized_By_EmpID "
End Sub
 

Users who are viewing this thread

Back
Top Bottom