Avatar of mlcktmguy
Flag 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?
Microsoft Access

Avatar of undefined
Last Comment
Mark Edwards

8/22/2022 - Mon
Fabrice Lambert

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.
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Jim Dettman (EE MVE)

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.

John Tsioumpris

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.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Jim Dettman (EE MVE)


 <<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.

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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
John Tsioumpris

@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.
Jim Dettman (EE MVE)

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.

Mark Edwards

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:

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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.