If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > TransferSpreadsheet to Dynamic Excel filename

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-28-04, 23:13
buckeye_td buckeye_td is offline
Registered User
 
Join Date: Sep 2004
Location: Charlotte, NC
Posts: 164
Question TransferSpreadsheet to Dynamic Excel filename

I have an Access 2000 database that I export several tables monthly to Excel spreadsheets using the TransferSpreadsheet in a macro. Each month after I export the tables to Excel, I then go to Windows Explorer and rename the files to add a suffix of MMYY (ie: 0904) to the names. Is there anyway to automate this when I export the tables.
Reply With Quote
  #2 (permalink)  
Old 09-29-04, 08:07
jepi jepi is offline
Registered User
 
Join Date: Sep 2004
Posts: 161
You can make this
FileName = "Table" & Format(Now,"mm/yy")
Docmd.TransferSpreadSheet acExport,8, "TbleAccess", Filename, etc...
Reply With Quote
  #3 (permalink)  
Old 02-06-10, 17:44
chavalomalo chavalomalo is offline
Registered User
 
Join Date: Feb 2010
Posts: 1
Adding Query Result to File Name

Thank you for posting that answer. In addition to including the date in a filename, is there a way to include an sql query in the parameters for the file name?

For example:
="C:\Folder\" & Format((select max([orderdate]) from SalesTable),"mm-dd-yyyy")&".xls"

BTW, this didn't work.
Reply With Quote
  #4 (permalink)  
Old 02-06-10, 20:06
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
You may find this example: http://www.dbforums.com/6390529-post84.html

helpful.

All you do is save any of your queries with a prefix of "Export" (or change the criteria), and it let's the user view/export the query as the query name (including adding the date format), and the type of export (dbf, xls, csv). The view opens up in a form view so you code events around the form. It uses the same docmd.transferspreadsheet command and some simple tricks.

Otherwise you need to create a variable and include the name of the query in your variable similar to jepi's example.
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Last edited by pkstormy; 02-06-10 at 20:10.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On