By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,326 Members | 2,726 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,326 IT Pros & Developers. It's quick & easy.

Transfer spreadsheet question

P: 30
I use the following code on a command button to export "Table1" into a spreadsheet called "Table1.xls.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command14_Click() Private Sub Command14_Click()
  2. stDocName = "Table1"
  3.  DoCmd.TransferSpreadsheet [acExport], , stDocName, _
  4.  "C:\ Export Folder\Table1.xls", 0
  5.  End Sub
This works fine but what I would like to do is save the spreadsheet like this: "Current Date"Table1.xls.
So if I did it today it would read "280808Table1.xls"
Any ideas how I can do this?

Thanks
Aug 28 '08 #1
Share this Question
Share on Google+
2 Replies


ADezii
Expert 5K+
P: 8,627
Expand|Select|Wrap|Line Numbers
  1. stDocName = "Table1"
  2.  
  3. DoCmd.TransferSpreadsheet [acExport], , stDocName, _
  4. "C:\ Export Folder\" & Format$(Date, "ddmmyy") & "Table1.xls", 0
Aug 28 '08 #2

NeoPa
Expert Mod 15k+
P: 31,434
May I suggest an amendment to that.

Dates in filenames are much more useful if they are done as YMD rather than DMY. This is clearer when four digit years are used.

The major benefit of this is that files viewed sorted by filename are automatically sorted by date too. It's also very easy to "lose" ones which are done DMY.
Expand|Select|Wrap|Line Numbers
  1. stDocName = Format(Date, "yyyymmdd") & "Table1.xls"
  2.  
  3. Call DoCmd.TransferSpreadsheet([acExport], , _
  4.                                "Table1", _
  5.                                stDocName, _
  6.                                0)
Aug 28 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.