|
|
Question : MS Access: Can a variable date be used in a title within a macro that exports a file?
|
|
I have a macro that exports data to a set location on the network with a fixed title. Works fine. I need to run this daily, and want to be able to keep the previous day's report. Is there a way to add today's date into the title of the export file? Example: Existing report title: SpecialReport.xls Can I automatically create this title: SpecialReport080211.xls. 080208 is today's date 2/11/08
|
Answer : MS Access: Can a variable date be used in a title within a macro that exports a file?
|
|
Not from within a Macro (least i don't think there is - I haven't used macros in years) but you can with DoCmd.TransferSpreadsheet. This method allows you to declare the location/title of the exported file. For example:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "YourQueryName", "C:\DataExport\SpecialReport" & Month(Date) & Day(Date) & Year(Date) & ".xls"
Would produce a file in the C:\DataExport folder named SpecialReport02112008.xls
|
|
|
|