Export a file

D

Dave Hawks

I want to automatically export a file every day using the timer property of a
form.
How can i do this without overwriting the existing file?. Can anyone suggest
some code that will rename the file as part of the save routine without
manual intervention.
Here is the current code I am using.
Private Sub Form_Timer()
DoCmd.OutputTo acOutputReport, "repToday", acFormatHTML,
"C:\WebsiteUploads\repToday.html", Yes, ""
 
O

Ofer Cohen

Try

DoCmd.OutputTo acOutputReport, "repToday", acFormatHTML,
"C:\WebsiteUploads\Rep" & Format(Date(),"yyyymmdd") & ".html", Yes, ""

The Resault will be
Rep20060716.html
 
A

Arvin Meyer [MVP]

Rename the file like this (aircode):

Private Sub Form_Timer()
Dim strOldName As String
Dim strNewName As String

strOldName = "C:\WebsiteUploads\repToday.html"
strNewName = "C:\WebsiteUploads\rep" & Format(Date, "mmddyy") & ".html"

On Error Resume Next ' If the file doesn't exist, just go on.
Name strOldName As strNewName

DoCmd.OutputTo acOutputReport, "repToday", acFormatHTML,
"C:\WebsiteUploads\repToday.html", Yes, ""

End Sub

--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
D

Dave Hawks

Thanks for the help
--
Dave Hawks


Arvin Meyer said:
Rename the file like this (aircode):

Private Sub Form_Timer()
Dim strOldName As String
Dim strNewName As String

strOldName = "C:\WebsiteUploads\repToday.html"
strNewName = "C:\WebsiteUploads\rep" & Format(Date, "mmddyy") & ".html"

On Error Resume Next ' If the file doesn't exist, just go on.
Name strOldName As strNewName

DoCmd.OutputTo acOutputReport, "repToday", acFormatHTML,
"C:\WebsiteUploads\repToday.html", Yes, ""

End Sub

--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
Top