Hi,
I'm saving my report as pdf and have written some VBA which exports the report to my desktop and assigns a custom name to the report based on the username and current date. It all works however despite my Win7 system date being correct the Date in code returns 22-11-2002. I think that I actually got the same date yesterday. My code is as follows:
Is there something I do wrong? Has anyone experienced simmilar problem. I have also tried to use Now() but that returns error and the action is cancelled while exporting the file.
Hope you can help.
Thanks,
Michal
I'm saving my report as pdf and have written some VBA which exports the report to my desktop and assigns a custom name to the report based on the username and current date. It all works however despite my Win7 system date being correct the Date in code returns 22-11-2002. I think that I actually got the same date yesterday. My code is as follows:
Code:
Private Sub Command18_Click()
On Error GoTo Command18_Click_Err
Dim Username As String
Username = Environ("UserName")
UserDate = Username & " - " & Date
TheFile = "LLIS Report - " & UserDate & ".pdf"
DoCmd.OutputTo acOutputReport, "ReportLLIS", "PDFFormat(*.pdf)", "C:\Users\" & Username & "\Desktop\" & TheFile & "", False, "", , acExportQualityPrint
TheMessage = "The Report has been succesfully exported to Desktop\" & TheFile
Beep
MsgBox TheMessage, vbInformation, "Report Save Complete"
Command18_Click_Exit:
Exit Sub
Command18_Click_Err:
MsgBox Error$
Resume Command18_Click_Exit
End Sub
Is there something I do wrong? Has anyone experienced simmilar problem. I have also tried to use Now() but that returns error and the action is cancelled while exporting the file.
Hope you can help.
Thanks,
Michal