Shut them Down

W

WireGuy

Did anyone find a way to shut an Access Database down if the user has not
been doing anything in the database for a time period; maybe a half hour?
I've recently had 2 issues in the past 2 weeks, were a user leaves the
database form open and possibly just shuts the computer or disconnects the
hard way and this causes a #delete in ever field of a record. At least that
is what I think is happening. I think if I tell them not to do this, it may
work for a while, but I would like a method to boot them out of a record and
back to the main switch board if they are not using the system. Any ideas,
will be appreciated.

Thanks,
John
 
D

Dale_Fye via AccessMonster.com

John,

There is no "simple" way to do this.

In order to do this, I would add a hidden unbound textbox (txt_LastActionAt)
to my "Splash" screen (the one that comes up when you load the application).
As soon as the application loads, I would set the value of that textbox using
the Now() function. Then, I would set the forms TimerInterval to something
like 60 thousand (1 minute) or maybe every 2 minutes (120000). Then, in the
TimerEvent, I would check to see whether the difference between the current
time (Now()) and txt_LastActionAt to determine whether the elapsed time
without activity exceeds your goal (20 minutes).

If it does, then you need to execute a procedure which sequentially closes
down all of the open forms. This is where things get tricky. You have to
decide which forms to close, and in what sequence (you might want to consider
maintaining an array which keeps track of the forms that are open, and the
sequence to close them in). You will also have to decide whether you will
discard all changes to the current record, or try to write those changes
before closing the form (this might vary depending on whether it is a new
record, or one that is being edited). You also might want to consider
building a mechanism that will take the user back to where he was when he was
logged off.

Finally, in each of your forms, you need to:
1. Add code that updates txt_LastActionAt during the forms load, current,
and close events
2. Turn the KeyPreview property to Yes, and in the KeyDown event, update the
txt_LastActionAt field
3. You might want to consider using the detail sections mouseMove event to
also update the txt_LastActionAt field.

This is a lot of work. If you create a template form, you could setup most
of this in the template, so that it would already be there when you copy that
form to start creating a new form.

HTH
Dale
 

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