Solved

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

Posted on 2008-06-25
2
547 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
2 Comments
 
LVL 18

Assisted Solution

by:jmoss111
jmoss111 earned 200 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 300 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

760 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

22 Experts available now in Live!

Get 1:1 Help Now