[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Save *.snp with current date()  in file name.

Posted on 2008-06-25
2
Medium Priority
?
623 Views
Last Modified: 2013-11-27
I would like to create a batch file or macro to automatically save a *.snp report to a folder with the Date()  in the *.snp file name.   I created a macro that creates the *.snp and saves to a network folder but I need to add the current Date() to the *.snp file name automatically.    What is happening now is, if one user saves the file and forgets to change the name to the date they ran the *.snp and the next user run the report it overwrites the existing copy.  

THOUGHTS
0
Comment
Question by:eyes59
[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
2 Comments
 
LVL 18

Assisted Solution

by:jmoss111
jmoss111 earned 800 total points
ID: 21869442
Hope this sample helps you oyt.

Jim
Dim ThisDay As String
Dim ThsDay As String
ThisDay = Date$
' Formats date to ISO format, IE YYYYMMDD
ThsDay = Right([ThisDay], 4) & Left([ThisDay], 2) & Mid([ThisDay], 4, 2)
             DoCmd.OutputTo acOutputReport, "rptHubSummaryWeekToWeek", acFormatSNP, "S:\SiteData\HSV2\Public\AppData\Reports\APWeekly\SupReports\" & ThsDay & "_" & "_RptHubsSummaryCompareWeekToWeek" & ".snp"

Open in new window

0
 
LVL 11

Accepted Solution

by:
RgGray3 earned 1200 total points
ID: 21871315
Place the following two functions in a standard module

Build your filename ...

"YourBaseFileName_" & IsoDateFormat(Date()) & ".snp"
(I like underscores seperating the base from the date stamp...  optional)

if multiple copies are needed a day.... use the IsoDateTimeFormat function
Public Function IsoDateFormat(pdtDate As Date) As String
    IsoDateFormat = Year(pdtDate) & Right("0" & Month(pdtDate), 2) & Right("0" & Day(pdtDate), 2)
End Function
Public Function IsoDateTimeFormat(pdtDate As Date) As String
    IsoDateTimeFormat = Year(pdtDate) & Right("0" & Month(pdtDate), 2) & Right("0" & Day(pdtDate), 2) & Right("0" & Hour(pdtDate), 2) & Right("0" & Minute(pdtDate), 2) & Right("0" & Second(pdtDate), 2)
End Function

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

649 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