By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,707 Members | 1,136 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,707 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?

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

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

Expert Mod 15k+
P: 31,754
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"
  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.