Access 2013 - Auto Log Out of the ACCDE users

DGWhittaker
DGWhittaker used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Jim Dettman (EE MVE)President / Owner
Most Valuable Expert 2017
Most Valuable Expert 2012
Commented:
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.
Database Architect / Application Developer
Top Expert 2007
Commented:
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
Most Valuable Expert 2014

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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial