How would I alter the below code to add a data and timestamp to an export?
After the & the datetime is showing up as file name.
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.