Quickie ! Adding Date/Time onto Excel sheet exported from Access

See attached code which generates a spreadsheet.

How do I add the date and time to the exported file name.
E.g. AccessDatabaseSalesExport_311211230859" or similar.

I tried a few things and failed!
DoCmd.TransferSpreadsheet acExport, 10, "qryExportTemp", "" , True, shtName

Open in new window

Patrick O'DeaAsked:
Who is Participating?
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPCommented:
Something like:

Dim strFileName as string

strFileName = "C:\AccessDatabaseSalesExport" & Format(Now(),"yyymmddhhmm") & ".xls" 

DoCmd.TransferSpreadsheet acExport, 10, "qryExportTemp", strFileName , True, shtName

Open in new window

Patrick O'DeaAuthor Commented:
Thank you !
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.