I have a form where the user enters a StartDate and EndDate to generate a report. If I want to export this report to a PDF, I would like the filename to include the StartDate and EndDate. I have the code below, which does not return any errors, but does not include the info in the file name.
Right now the file name just comes out as "Program Statistics from to .pdf"
Any thoughts on getting the file name to include the dates?
Code:
Sub GetStartDate()
Dim StartDate As String
StartDate = [Forms]![frmDatabaseReports]![StartDate]
End Sub
Sub GetEndDate()
Dim EndDate As String
EndDate = [Forms]![frmDatabaseReports]![EndDate]
End Sub
Private Sub btnExportPDF_Click()
TestForDir
GetStartDate
GetEndDate
Dim strfilename As String
strfilename = "C:\Users\" & Environ("username") & "\Desktop\Database Reports\Program Statistics from " & StartDate & " to " & EndDate & ".pdf"
DoCmd.OutputTo acOutputReport, "rptProgramStatsByDate", acFormatPDF, strfilename, True
End Sub
Right now the file name just comes out as "Program Statistics from to .pdf"
Any thoughts on getting the file name to include the dates?