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
Microsoft AccessVBA

Avatar of undefined
Last Comment
Nick67

8/22/2022 - Mon
SOLUTION
Jim Dettman (EE MVE)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Nick67

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.
Your help has saved me hundreds of hours of internet surfing.
fblack61