Data Base Left open

sandrao

Registered User.
Local time
Today, 15:37
Joined
Sep 6, 2007
Messages
34
How can I stop agents from leaving a database open after they have finished there days work. I maintain and modify a database from home, but some agents forget to close the database at the end of the day. That prevents me from doing any modification on the database. Maybe a simple message that would come up and close on a regular timed bases. Or some other simple way of reminding them to close before leaving for the night.
 
My idea would be to have a form (maybe a switchboard or some other likely candidate that is always open) use the ontimer event to check the time every half hour or so.

If the time is after the close of business then have the ontimer event open another notification form with it's own on_timer event and a message saying to close the form within 30 seconds or the database will shutdown on its own.

Have the ontimer event on this form running every 30 seconds and use it to run the quit database command

Docmd.Quit



If they close the notification form before the code runs they can stay in the db until the next time check in half an hour where they'll have to repeat the experience.


If you don't have a form that is always open, then create one that is opened at startup and then becomes invisible to the user.

HTH
 
The timer is definitely the way to go. We use that here across the country to throw people out of the DB. Yes, we warn them (60 minutes, 30 minutes, and it 5 minutes before shutdown). After that, it saves any open records and closes the DB.

A better trick would be to keep the users out of the DB for a specific time. For example, you want me out of the DB at 5pm. I'm in a meeting from 4pm to 5pm. Having missed all the warning messages, I come back to my desk at 5:05pm, and I need the DB, so I open it. You don't want that to happen either.

The trick here is to check a table (t_AutoTimers, or something that makes sense to you). In that table, you have have fields like this:

AutoLogout (boolean)
TimeoutStart (date/time)
TimeoutResume (date/time)

You set AutoLogout to on/off depending on who you want to be automatically kicked out. For example, you probably don't want yourself to be automatically kicked out, so you'd set that to No for your copy of the DB.

TimeoutStart is the time when your users are automatically kicked out. Easy enough.

TimeoutResume is the time that your users can get back in. Therefore, in the AutoExec of your DB, you compare Now() to the Time in the TimeoutResume field. If Now() < TimeoutResume, a messagebox pops up ("Sorry, the database is under maintenance. Your DB will be available at " & TimeoutResume & "." (Use the DateDiff function to compare two time values.)

This way, you can automatically log out your users, and you can automatically keep them out for X amount of time while you do your maintenance.
 
Thanks for all the ideas. I need a little more clarification on how to code the AutoExec fucntion. And how to code the time for example shut people out after 5:30pm.

Thank for the help thus far
 
Basically what you need to do is create an invisible form and set it as your start up form. Then you can open your swithboard on the open event of the invisible form. Next use the timer event to run some code to check if the current time is past 5.
 
As directed, set a form to open when the database opens (the invisible form). Set the startup form in Tools -> Startup form/page.

From there, experiment with the timer control. Set it to 10 seconds (10000, since the timer works in milliseconds). Every time it reaches that, display a message box of some sort, like "10 second timer ran". You're just testing here to make sure you get how it works. (It's the OnTimer event.)

After it makes sense to you, that's when you start to implement the more complex operations that you're after. The code only makes sense if you understand it, which is why it's not just being written for you. You have to experiment and have it make sense to you.
 
Thanks for everyone help. I have experimented with the Timer and I am confident that this is the way to go. I am experiencing a problem with the code part. e.g. I would like the database to be turned off lets say every night at 8:00 PM. By that time everyone is out of the office. But as mentioned above some have left the database open. I was using the code:

If Now() => #8:00:00 pm# then DoCmd.Quit

It seems to be closing the DB even if it is not > 8:00:00 PM.

What is wrong with the code?

Any ideas
 
Try using Time() instead of Now().
 
Thanks to everyone for there help. The using of Time() solved the problem.
Thanks once more.
 

Users who are viewing this thread

Back
Top Bottom