Hello,
I want to automatically save a report to a pdf with automatic naming by clicking a button:
- report name : rptTest
- name of the pdf-file : number-initials-date.pdf (e.g 2156598-SRU-20171222.pdf)
I am getting the error message "The action or method requires a Report Name argument."
What am i doing wrong?
I used the following code :
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Dim Number As String
Dim Initials As String
Dim Date As String
Dim Filename As String
Dim Path As String
Number= Me.Number.Value
Initials = Me.Initials.Value
Date = Year(Now()) & "" & Month(Now()) & "" & Day(Now())
Filename = Number & "-" & Initials & "-" & Date & ".pdf"
Path = "D:\Documents\Projecten\Database" & Filename
DoCmd.OpenReport rptTest, acPreview
DoCmd.OutputTo acOutputReport, "rptTest", acFormatPDF, Path, True
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub