Date/Time stamp for exported reports?

bowes884

Registered User.
Local time
Today, 11:33
Joined
May 25, 2005
Messages
33
Is there a way I can get a date/ time stamp for reports. I run a macro that creates a report and converts it to RTF in a server file. I want the name of the report to also contain the date and time modified. Help please.

Bowes
 
They already have that. I need something so when The file is updated, I can view it in its folder and know which one is the most up-to-date one because it has the date in the name.

Bowes
 
You need to add the Date and Time to the file name when you export the report. You will need to format the time stamp when you create the file name. This should give you an idea of what I mean using VBA [I do not use macros].

Code:
Dim sNow As String
Dim sPath As String

sNow = Format(Now(), "mmddyyyy-hhmmss")
sPath = "X:\ReportFiles\"

DoCmd.OutputTo acOutputReport, "YourReportName", acFormatRTF, sPath & "ReportName" & "_" & sNow & ".rtf", False
 
Here is the code below that I use to export the file. How can I get the date/time stamp into this? Please help!! Very appreciated.

Bowes

Function autoexec()
On Error GoTo autoexec_Err

DoCmd.SetWarnings False
SendKeys "y", False
DoCmd.OutputTo acReport, "LOCKS - Detail", "RichTextFormat(*.rtf)", "Y:\0001 Secondary Marketing Reports\14 - Lock Summary.rtf", False, ""
SendKeys "y", False
DoCmd.SetWarnings True
SendKeys "y", False


autoexec_Exit:
Exit Function

autoexec_Err:
MsgBox Error$
Resume autoexec_Exit

End Function
 
Here is an updated code thats a little cleaner. I tried putting in the code you gave me and there are onlyy parts of it in there. Here it is:

'------------------------------------------------------------
' Test_Locks_macro
'
'------------------------------------------------------------
' autoexec1
'
'------------------------------------------------------------
Function autoexec1()
On Error GoTo autoexec1_Err

DoCmd.SetWarnings False
Dim sNow As String
Dim sPath As String
sNow = Format(Now(), "mmddyyyy-hhmmss")
sPath = "X:\ReportFiles\"
SendKeys "y", False
DoCmd.OutputTo acOutputReport, "LOCKS - Detail", acFormatRTF, "Y:\0001 Secondary Marketing Reports\14 - Lock Summary.rtf", False, ""
DoCmd.SetWarnings True


autoexec1_Exit:
Exit Function

autoexec1_Err:
MsgBox Error$
Resume autoexec1_Exit

End Function
 

Users who are viewing this thread

Back
Top Bottom