Link to home
Start Free TrialLog in
Avatar of mlcktmguy
mlcktmguyFlag for United States of America

asked on

How to force users out of an Access application after a certain period of inactivity

I need to do some work on a client's DB.  Despite the clients best efforts and repeated emails some user don't close the Access 2013 application when leaving for the day.  I did some research on forcing user out of the DB after some period of inactivity and came up with this solution on the Microsoft website.

Microsoft Suggestion For Forcing User Out of an Application

I am hesitant to use this one due to its use of 'TimerInterval'.  Somewhere along the line in my many years of Access development I remember being warned against using the 'TImerInterval' because in some way it could become problematic.  

Do any of you have experience with the having to remotely shutdown users due to inactivity?  DId you use the 'TImerInterval' function or are there better methods?
Avatar of Fabrice Lambert
Fabrice Lambert
Flag of France image

Well, MS Access wasn't build with real time in mind, but it work (more or less).

Be warned that sometimes, user shut down the application, but for whatever reasons, a connection remain open, so it isn't an absolute solution.
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One important thing here is that you not force the user out outside of the application.   That can corrupt the DB.

 There is a passive shutdown feature built into Access, but that relies on the user to exit (it just prevents new users from connecting to the DB).

 So whatever you do, it needs to be built into the app.   Usually that involves setting some type of flag, then within the app, checking for that flag and doing the exit from the app.

Jim.
Well there is another way...(too bad i don't have the time to polish it and release it) ...you just could locate the database on the BE and close them...like connecting to the machine that "holds" the back end
The Manual way --> Shared Folders --> Open Files --> Close Them
The Automatic way  --> it can be done via VBA.
@John,

 <<The Manual way --> Shared Folders --> Open Files --> Close Them>>

  You absolutely do not want to do this on a JET/ACE database.   You never want to force close a connection.

  If you do it this way, you have to be absolutely sure the user is idle.  If they are working with the DB, you can corrupt the DB.

Jim.
Avatar of Daniel Pineault
Daniel Pineault

There is nothing wrong with using a Timer.  Obviously, you don't want to run a timer on every form ..., but in the context that you are talking about it is absolutely fine.

As for what can be done, I urge you to look over the following 2 solution (similar, but for different applications).


I've been using them in pretty much all my databases for 10+ years and never had any issues whatsoever.
The timer is more of a danger to you during development.  That is what you need to watch out for.  In the rare instances where I use a timer for anything, I add code to the open event of the opening form to check to see if it is me opening the database.  If it is me, I pop up a question asking if I want to run the timer events.  I say yes if the timer event code is what I am testing.  I say no in all other cases and the code sets the timers all off.  What you are trying to avoid is opening an object and making design changes when there is an open form with a timer event running.  You can loose your changes and it can corrupt the database.
@Jim in the 10+ years i have used in a heavy environment of 100+ users i can't remember if i had a case of corruption.
Depends on when your trying it.  Again, if there is not activity, you can get away with it.

 But this is no different than doing a CTRL/Alt/Del, Rebooting the server, etc.   None of which you want to do with a JET/ACE DB.

 Your terminating the connection without closing the DB through Access.

Jim.
I've used the timer in my app shell that I use to build new apps with.  Just watch the demo to see how it works:
https://www.youtube.com/watch?v=-A8fu--aa6k

It depends on how you close out.  There is a difference between "close" and "quit".  If you try to close gracefully and a popup (to save or do whatever) opens, then it can halt your closing code.  You'll want to avoid this by just "Quit", but even then, no guarantees that everything will work right.