Access 2013 - Auto Log Out of the ACCDE users

Is there a way to set up the ACCDE file to automatically log folks out either after a period of non-use or possibly every day at 2:00 a.m.?

Open users are affecting my ability to update/import data.

Thanks!
Dennis
DGWhittakerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Couple different approaches, but whatever you do, it must be built into the app.   Disconnecting a JET/ACE user externally can lead to corruption.

1. Set a "flag" of some type that gets checked every xx minutes.  Do this in a startup form (hidden) with a timer event.  If the flag is set, message the user or do Application.Quit.

 The flag can be anything; a file on disk, entry in a table, etc.

 To help with that, you can place a "resource lock" with the code here:

Resource locking in your applications
http://www.experts-exchange.com/articles/5328/Resource-locking-in-your-applications.html

2. Then and/or check for inactivity:

ACC: How to Detect User Idle Time or Inactivity
https://support.microsoft.com/en-us/kb/128814

 Again, hidden form, timer event, but now your checking screen.activeform and screen.activecontrol to see if things are changing.

 An alternative to that would be to place "resource locks" when a use does something (like open a form) and then remove them and log that when you do.

Jim.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Peter has two free utilities to do this, and has figured *everything* out for you. Comes with sample db.
I turned the Force Shut Down into a full blown forced shutdown that is used daily to close dbs for backup.  I highly recommend these - pick the one that best suits your need.


Inactive Shut Down Control
http://peterssoftware.com/isd.htm


Force Shut Down
http://peterssoftware.com/fsd.htm

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nick67Commented:
I built it in VBA.
I have a form that loads hidden as one of the first things the app does.
It has some code
Here's the declarations.
I want things to close at 9 PM
Option Compare Database
Option Explicit
Const timeToRun As Date = #9:00:00 PM#
Const DelayFromLastActivity As Long = 5
'minutes of delay

Open in new window


some OnLoad code, to set a timer interval

Private Sub Form_Load()
If DateDiff("s", Time(), timeToRun) < DelayFromLastActivity Then
    TheInterval = DelayFromLastActivity * 60 * 1000
Else
    TheInterval = DateDiff("s", Time(), timeToRun) * 1000
End If
Me.TimerInterval = TheInterval
DontSkipMessage = True
End Sub

Open in new window


Some code to quit the application if the timer goes off
I have a message to users when they try to quit allowing a cancel.
They always click the wrong X
Private Sub Form_Unload(Cancel As Integer)
Dim response As Integer
If DontSkipMessage = True Then
    response = MsgBox("Did you really intend to quit The Program? Yes to Quit, no to remain in The Program", vbYesNo + vbCritical, "Quit?")
    If response = vbNo Then
        Cancel = True
        If Application.CurrentProject.AllForms("frmStartupScreen").IsLoaded = False Then
            DoCmd.OpenForm "frmStartupScreen"
        End If
    End If
End If
End Sub

Open in new window


In a code module, I have
Global DontSkipMessage As Boolean
Public TheInterval As Long

Open in new window


Then in any of the forms likely to be active, I have code to bump theInterval back past 9:05 PM if they are working on the form.
The locations of that code vary because of the nature of the forms I monitor, but it is basically like the OnLoad code.

If this timer event goes off, the app quits.
And the timer event only happens once!
No Timer heartbeat grief.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.