Solved

Current Date as File Name

Posted on 2014-07-24
9
294 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

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.  

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

832 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