?
Solved

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

Posted on 2008-06-25
2
Medium Priority
?
611 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

Technology Partners: 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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

765 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