Save An Report Automatically every 10 days

whojstall11

Registered User.
Local time
Yesterday, 23:51
Joined
Sep 7, 2011
Messages
94
I have a code that saves an report every time i click an button i have created. Can you tell me a way to have this report automatically save every 10 days. Without pressing an button.

PHP:
Dim stDocName As String
mystr = Format(Date, "dddd-mmmm-yyyy")
If Len(Dir("C:\Documents and Settings\JStallworth\Desktop\Reports" & mystr, vbDirectory)) = 0 Then MkDir "C:\Documents and Settings\JStallworth\Desktop\Reports" & mystr
stDocName = "Depreciation Report2"
DoCmd.OutputTo acOutputReport, stDocName, "RichTextFormat(*.rtf)", "C:\Documents and Settings\JStallworth\Desktop\Reports" & mystr & "\Depreciation Report2 " & Format(Now, "(hh-nn AMPM)") & ".rtf"
 
Personally I would probably create a new db that ran that process when it opened, then it closes itself. Then I'd run that db from Windows Scheduled Tasks.
 
Yea I just did some research on the Window Scheduled Task but why would you create another db?
 
That was based on the assumption that the db the code is in now has lots of other things in it, and you wouldn't want it doing this on start up. If that's not the case, you certainly don't need a new one.
 
ok but im reading how to do this and they said save my macro to the desk top and have the window scheduler open the macro from there. My question: is there any way to have my code run from the macro? Because right now it is link to a button and runs when clicked. I dont want to change it to a function basically.
 
I'd copy/paste that code into a public function in a standard module, then call that function from an autoexec macro. That way it automatically runs when the db opens. I suppose if you made the button code public you could run it, but frankly I wouldn't bother.
 

Users who are viewing this thread

Back
Top Bottom