Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export a .csv file with today's date?

Status
Not open for further replies.

surfbum3000

Technical User
Aug 22, 2003
156
US
I created a Macro that exports a table to a .csv file. I manually edit the filename to today's date. Is there a way to automatically have the filename to include the date the file was created?

Action Arguments

Transfer Type: Export Delimited
Specification Name:
Table Name: tblAppts
File Name: C:\filename04_14_2004.csv
Has Field Names: Yes
HTML Table Name:
Code Page:
 
Function SaveFile()
Dim todaysdate As String
Dim today As String
todaysdate = Date
today = Format(todaysdate, "dd_mm_yyyy")
Debug.Print todaysdate
Debug.Print today
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "tblAppts
", "c:\filename" & today & ".csv", False
End Function
 
Thank you for your response. I am not familiar enough with Access 2000 to know where to put this code. Do I copy and paste it into a module?
 
I copied and pasted the above code into a Module. Next, I clicked on Debug --> Step Into. I then receive the following error: "Compile error: syntax error" at the line

", "c:\filename" & today & ".csv", False
 
You could be getting the syntax error as the code is running onto two lines. Try changing the code to the following
Code:
DoCmd.TransferSpreadsheet acExport,_ acSpreadsheetTypeExcel97, "tblAppts _
", "c:\filename" & today & ".csv", False

HTH 

Elise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top