Solved

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

Posted on 2008-06-25
2
571 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

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.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

822 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