Forum Discussion
Tony2021
Dec 23, 2021Steel Contributor
Print Report to PDF and append Date to file name
Hello, I want to add a date in YYYYMMDD format to the file name below. I cant seem to get it to work.
the file name should be Pending 20211223.pdf
the below code is not correct (bold part)
Private Sub cmdExport_Click()
DoCmd.OutputTo acOutputReport, Me.Name, acFormatPDF, "C:\Users\Me\OneDrive\Documents\" & "Pending" + DateTime.Now.pdf, True, "", 0
End Sub
thank you
- you can Format$() the Date/Time:
"C:\Users\Me\OneDrive\Documents\" & "Pending" + Format$(Now(), "yyyymmdd") & ".pdf"