Solved

Current Date as File Name

Posted on 2014-07-24
9
300 Views
Last Modified: 2014-07-30
What to i put in the Highlighted section to get the current date as my file name
See attached Screen shot.


Access Screen shot
0
Comment
Question by:garyrobbins
  • 3
  • 3
  • 2
9 Comments
 
LVL 1

Expert Comment

by:pdi656
ID: 40217890
I'm not sure if you can accomplish that using the Macros GUI - it doesn't seem to like quotes around the file name. You can do it in code however:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, [Daily AR Trending], "A:\1. Robbins, John\Daily AR Trending\" & Format(Date(), "yyyymmdd hh:mm"), False

Open in new window


You could put this under a button on a form and call it from the click event or even create a public method in a module and run that from a macro (Run Code as the macro action).  Of course "acSpreadsheetTypeExcel9" may have to change depending on your version of Excel.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40217899
gary,

I'm assuming this is a continuation of your previous thread.  It is never a good idea to start a new thread, simple keep the old one going.
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 40217925
See my latest response there
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:garyrobbins
ID: 40217929
Oh, Ok.  New to Exchange I will keep that in mind. Thanks.
0
 

Author Comment

by:garyrobbins
ID: 40217931
I have not coded outside of The Macro Gui before, how would go about doing that?
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40217944
#1.  Close (Delete) this question.

#2.  Go back to the other one, and I'll explain there how to create that user defined function.
0
 
LVL 1

Expert Comment

by:pdi656
ID: 40217949
Create a new module (on Create tab). A new window will pop up. In the module put the following code:

Public Sub Export_Data()

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, [Daily AR Trending], "A:\1. Robbins, John\Daily AR Trending\" & Format(Date(), "yyyymmdd hh:mm"), False

End sub

Open in new window


Save the module - you can call it anything you want.
In your macro, select RunCode as the action. The function name is Export_Data()
0
 
LVL 1

Expert Comment

by:pdi656
ID: 40217994
Actually, now that I see what Dale was doing in his other post, this should work in the macro's output file box:

="A:\1. Robbins, John\Daily AR Trending " & Format(Date(), "yyyymmdd hh:mm") & ".xlsx"


I tried ="C:\Temp\test" & Format(Date(),"yyyy") & ".xls" as a test and got a file called "test2014.xls"
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question