Link to home
Start Free TrialLog in
Avatar of DGWhittaker
DGWhittaker

asked on

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
SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
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
ASKER CERTIFIED SOLUTION
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
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.