Running a function once a month

ZedtheHead

No clue about Access user
Local time
Today, 13:42
Joined
Jan 11, 2005
Messages
15
I currently have a function which is manually executed on the press of a button. What I would like is to have code execute once a month automatically.

Is this possible or plausible in VB? ? And how would it cope with the fact that the program would not be running 24/7?
 
I have a program on one of my databases that was set to run weekly. For example, in order to do this I created a form and on the form's On_Load property I wrote code that checked the computer's date/time to see if it was Monday 7:00AM. If this was true then execute code; otherwise exit the database.

Next create a macro to open the form, save the macro and call it "autoexec". What this does is if you have a macro called autoexec then anytime the database is opened it will automatically run the macro. (To avoid running the autoexec when opening database you simply hold the shift key down while opening the database)

Lastly I used windows task scheduler to open the database at the desired time to run the database and exit the program.


I'm sure someone may have a more elegant approach; however, I did find this to work well.
 
Thanks for replying.

I'm not at all concerned about an elegant (or not) solution. I just want it to work!

If I used windows task scheduler to open the database, but the database was already open, would that trigger the autoexec?
 
I do this differently. I add a table that contains the last run date and a form bound to that table. I use that as my startup form. In the form's current event I compare the last update data with the current date and determine if it is time to run the monthly process. If it is, I run it, update the date, open the normal startup form, and close the special form. Otherwise I just open the normal startup form and close the special form.
 

Users who are viewing this thread

Back
Top Bottom