Solved

Current Date as File Name

Posted on 2014-07-24
9
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 48

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 48

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 40217925
See my latest response there
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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 48

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
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‚Ķ

691 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