How to add date and timestamp to export

tmcrouse

Registered User.
Local time
Today, 10:16
Joined
Jun 12, 2012
Messages
14
How would I alter the below code to add a data and timestamp to an export?

Code:
[SIZE=3][FONT=Calibri]Private Sub cmdExcel_Click()[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]DoCmd.OutputTo acOutputQuery, "qryResults", "ExcelWorkbook(*.xlsx)", "C:\users\" & Environ$("username") & "\Documents\qryResults & datetime.xlsx", , , , acExportQualityPrint[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]msgbox ("Export completed. Please click reset to return to original results.")[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]End Sub[/FONT][/SIZE]

After the & the datetime is showing up as file name.
 
You've have to concatenate it into the string, the same way you did with the user name. I'd useL

Format(Now(), "yyyymmddhhnn")
 

Users who are viewing this thread

Back
Top Bottom