Solved

Current Date as File Name

Posted on 2014-07-24
9
273 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
Comment Utility
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)
Comment Utility
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
Comment Utility
See my latest response there
0
 

Author Comment

by:garyrobbins
Comment Utility
Oh, Ok.  New to Exchange I will keep that in mind. Thanks.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:garyrobbins
Comment Utility
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)
Comment Utility
#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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Query Missing Money orders... 6 62
Access 2010 ComboBox Requery Not Working 17 24
Access MDB/PDF 21 28
TT Column Arrange 10 27
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…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

744 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

21 Experts available now in Live!

Get 1:1 Help Now