Access VBA Timer Event
The Microsoft Access Form Timer event allows you to execute a macro or piece of code automatically at set intervals. This is something you would use to periodically update some records, refresh some data, or have any sort of timed database event.
You may have the urge to stretch that definition into a question such as, "Can I have Access automatically do XYZ every night while I'm sleeping safe and sound at home?"
Don't fall into that trap. The Form Timer event is generally used very rarely and for good reason. First, you must have Access open in order for this to occur. Second, you must have that specific Form open as well. Third, there's a limit of 65,000 milliseconds for intervals. There's no easy scheduling such as, "At 9:00PM run this code."
Futhermore, little problems like network access, low resources, and general instability can really wreak havoc with something that's on a timed event. For small processes and relatively low-importance tasks, the Form Timer event might be a good way to go, but if you need on-the-clock processing to be done, it's better to stick with something slightly more reliable …
Enter: Task Scheduler. This Windows utility can open an application at a specific time which can in turn run code. Again, you'll be facing similar "timing" issues such as making sure the PC is on during the time that this event should occur and making sure that everything is in working order for it to process it's data.
If you happen to work in an office where co-workers are kind enough to shut your PC down at night, you could have issues with the code not running. If network maintenance is being done at the same time that your code is scheduled to run, you could have further problems. There are many variables outside of your scope of control that may cause poor results.
Your best rule of thumb is to have a look at the process being done. If that process were to fail, would your database be in horrific shape? Would dozens of people be knocking at your door ready to scream? Then don't use a timer event or the task scheduler. Find another way to get the job done at a different time, or use a different system that's somewhat more robust in order to achieve your results. The last thing you want to do is set up some automation and have something go terribly wrong while you were at home sleeping safe and sound.
In the years that I've been designing databases, I've not had a single occasion where a Timer event has been absolutely necessary. Most clients are more than happy launching a set of automated tasks manually considering the bad alternative of a loss of data or more importantly, a loss of time.
©2014 Blue Moose Technology, LLC
Article Publishing and Re-Print Guidelines
- The article text, resource box, URLs copyright information and these guidelines must be left intact and unchanged.
- When re-published online, all links must be live hyperlinks.
- These articles may not be distributed in any manner that does not comply with federal communication guidelines. Be Good!
- These articles must not be password protected or limited to membership or paid-only viewing. Keep 'em free, folks!
You can easily link to this article!
If you'd like to link to this article from your own website, copy and paste the following HTML code onto your page:
On your page, the code will appear like this: