Solved

Current Date as File Name

Posted on 2014-07-24
9
279 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
 

Author Comment

by:garyrobbins
ID: 40217929
Oh, Ok.  New to Exchange I will keep that in mind. Thanks.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now