Close DB On A Schedule

G

Guest

I need to close an Access DB before the end of the day as it is linked to a
file (and locks the file) that my server overwrites every night. Someone
left the DB I developed open last night and an error occured (due to the file
lock) and created a mess (other scheduled tasks did not run). Is there a way
to automatically shutdown this DB after X period of time or at X hour. I
would like to use both (as a safegaurd in case of time errors on other PCs).
I could code this in a module if need be I was wondering if there is a better
way.
 
G

Graham R Seach

Robert,

The easiest way is to have a hidden form that loads when the database starts
up. In this form, you have the Timer event firing every minute (or every 5
minutes), to check for a specific time of day (say 5PM). When this time is
reached, issue the following line:
Application.Quit acQuitSaveAll

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
A

aaron.kempf

MDB is a waste of time. you can do this type of thign in ADP quite
easily; using the KILL command.

but the point of the matter is that DATA is valuable enough to keep in
a real database. if you care enough to back it up every night; you
should be using SQL Server.

-Aaron
 
T

Tony Toews

Robert_DubYa said:
I need to close an Access DB before the end of the day as it is linked to a
file (and locks the file) that my server overwrites every night. Someone
left the DB I developed open last night and an error occured (due to the file
lock) and created a mess (other scheduled tasks did not run). Is there a way
to automatically shutdown this DB after X period of time or at X hour.

You'd need to add the VBA code to also look at a shut down time but
that shouldn't be a problem.

HOW TO: Detect User Idle Time or Inactivity in Access 2000 (Q210297)
http://support.microsoft.com/?kbid=210297
ACC: How to Detect User Idle Time or Inactivity (Q128814)
http://support.microsoft.com/?kbid=128814

However we found that the code which runs on the timer event must be
disabled for the programmers. Otherwise weird things start happening
when you're editing code.

Also print preview would sometimes not allow the users to run a menu
item to export the report to Excel or others. So you had to right
click on the Previewed report to get some type of internal focus back
on the report so they could then export it. This was also helped by
extending the timer to five minutes.

The downside to extending the timer to five minutes was if a person
stays in the same form and at the same control for considerable parts
of the day, ie someone doing the same inquiries, the routine didn't
realize that they had actually done something. I'll be putting in
some logic sometime to reset this timer whenever they do something in
the program.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top