Any suggestions on how to setup a multi-user database to shutdown automatically when inactive for a specified period of time, while allowing Mousemove, keypress to prevent shutdown and reset the shutdown timer. Thanks
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Shutdown on inactiviy (Access 2K SP1)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Shutdown on inactiviy (Access 2K SP1)
- This topic has 14 replies, 4 voices, and was last updated 21 years, 5 months ago.
Viewing 5 reply threadsAuthorReplies-
WScharlotte
AskWoody LoungerDecember 4, 2003 at 1:33 pm #752851 -
WSgrozy
AskWoody LoungerDecember 4, 2003 at 1:47 pm #752864The database I have tracks usage and is considered sensitive. Many of my users are complacent so I setup an inactive shutdown based off of how long a control has been active. But now when users may be reading something or entering data within one control the system shuts them down. I like it to shutdown on only the active machine. I have the below associated with a specific form which is hidden when a user enters the system.
Option Compare Database
Option Explicit
Const conSeconndsPerMinute = 60
Dim sngStartTime As Single
Dim ctlSave As Control
Dim intMinutesUntilShutDown As Integer
Dim intMinutesWarningAppears As IntegerPrivate Sub Form_Close()
On Error Resume Next
ctlSave = Nothing
End SubPrivate Sub Form_Open(Cancel As Integer)
‘* Set this variable to the number of minutes of inactivity
‘* allowed before the application automatically shuts down.
intMinutesUntilShutDown = 5
‘* Set this variable to the number of minutes that the
‘* warning form will appear before the application
‘* automatically shuts down.
intMinutesWarningAppears = 1
Me.Visible = False
sngStartTime = Timer
End SubPrivate Sub Form_Timer()
‘**********************************************************************
‘* This timer event procedure will shut down the application
‘* after a specified number of minutes of inactivity. Inactivity
‘* is measured based on how long a control remains the ActiveControl.
‘**********************************************************************
Dim sngElapsedTime As Single
Dim ctlNew As Control
On Error Resume Next
Set ctlNew = Screen.ActiveControl
If Err 0 Then
‘* No activecontrol
sngElapsedTime = Timer – sngStartTime
Else
If ctlNew.Name = “InactiveShutDownCancel” Then
‘* The warning form has appeared, and the cancel button
‘* is the active control
sngElapsedTime = Timer – sngStartTime
Else
If ctlNew.Name = ctlSave.Name Then
‘* Still at same control
sngElapsedTime = Timer – sngStartTime
Else
‘* Some change has occured, we’re at a new control
Set ctlSave = ctlNew
sngStartTime = Timer
End If
If Err 0 Then
Set ctlSave = Screen.ActiveControl
End If
End If
End If
Err.Clear
Set ctlNew = Nothing
‘Debug.Print ” active control=” & ctlNew.name & ” elapsed=” & sngElapsedTime
Select Case sngElapsedTime
Case Is > (intMinutesUntilShutDown * conSeconndsPerMinute)
‘MsgBox “QUIT”
Set ctlSave = NothingCase Is > ((intMinutesUntilShutDown – intMinutesWarningAppears) * conSeconndsPerMinute)
‘* Make the warning form visible
Me.Visible = True
Case Else
‘* The next line can be commented out if the form is opened hidden
‘Me.Visible = False
End Select
Exit_Section:
End SubPrivate Sub InactiveShutDownCancel_Click()
sngStartTime = Timer
Me.Visible = False
End Sub -
WSgrozy
AskWoody LoungerDecember 4, 2003 at 1:47 pm #752865The database I have tracks usage and is considered sensitive. Many of my users are complacent so I setup an inactive shutdown based off of how long a control has been active. But now when users may be reading something or entering data within one control the system shuts them down. I like it to shutdown on only the active machine. I have the below associated with a specific form which is hidden when a user enters the system.
Option Compare Database
Option Explicit
Const conSeconndsPerMinute = 60
Dim sngStartTime As Single
Dim ctlSave As Control
Dim intMinutesUntilShutDown As Integer
Dim intMinutesWarningAppears As IntegerPrivate Sub Form_Close()
On Error Resume Next
ctlSave = Nothing
End SubPrivate Sub Form_Open(Cancel As Integer)
‘* Set this variable to the number of minutes of inactivity
‘* allowed before the application automatically shuts down.
intMinutesUntilShutDown = 5
‘* Set this variable to the number of minutes that the
‘* warning form will appear before the application
‘* automatically shuts down.
intMinutesWarningAppears = 1
Me.Visible = False
sngStartTime = Timer
End SubPrivate Sub Form_Timer()
‘**********************************************************************
‘* This timer event procedure will shut down the application
‘* after a specified number of minutes of inactivity. Inactivity
‘* is measured based on how long a control remains the ActiveControl.
‘**********************************************************************
Dim sngElapsedTime As Single
Dim ctlNew As Control
On Error Resume Next
Set ctlNew = Screen.ActiveControl
If Err 0 Then
‘* No activecontrol
sngElapsedTime = Timer – sngStartTime
Else
If ctlNew.Name = “InactiveShutDownCancel” Then
‘* The warning form has appeared, and the cancel button
‘* is the active control
sngElapsedTime = Timer – sngStartTime
Else
If ctlNew.Name = ctlSave.Name Then
‘* Still at same control
sngElapsedTime = Timer – sngStartTime
Else
‘* Some change has occured, we’re at a new control
Set ctlSave = ctlNew
sngStartTime = Timer
End If
If Err 0 Then
Set ctlSave = Screen.ActiveControl
End If
End If
End If
Err.Clear
Set ctlNew = Nothing
‘Debug.Print ” active control=” & ctlNew.name & ” elapsed=” & sngElapsedTime
Select Case sngElapsedTime
Case Is > (intMinutesUntilShutDown * conSeconndsPerMinute)
‘MsgBox “QUIT”
Set ctlSave = NothingCase Is > ((intMinutesUntilShutDown – intMinutesWarningAppears) * conSeconndsPerMinute)
‘* Make the warning form visible
Me.Visible = True
Case Else
‘* The next line can be commented out if the form is opened hidden
‘Me.Visible = False
End Select
Exit_Section:
End SubPrivate Sub InactiveShutDownCancel_Click()
sngStartTime = Timer
Me.Visible = False
End Sub
-
-
WScharlotte
AskWoody LoungerDecember 4, 2003 at 1:33 pm #752852 -
WSHansV
AskWoody LoungerDecember 4, 2003 at 1:42 pm #752859Microsoft provides a simplistic example of detecting if the user moves to another control or form in HOW TO: Detect User Idle Time or Inactivity in Access 2000.
But if you would like to detect mouse moves (and keystrokes), you would have to create event handlers for all forms and all their controls. And reports don’t have On MouseDown or On KeyPress events…
-
WSgrozy
AskWoody LoungerDecember 4, 2003 at 2:43 pm #752892I’ve narrowed it down to one specific control on a user common form that I’d like to prevent the shutdown from occuring if keypress or mousemove. Could you provide an example of an event handler which would reset the time established on my inactive form shutown(provided in earlier post). Thanks.
-
WSHansV
AskWoody LoungerDecember 4, 2003 at 10:23 pm #753126You would have to move the declaration of sngStartTime to a standard module:
Public sngStartTime As Single
The Form_Timer routine of the hidden form can be simplified to
Private Sub Form_Timer()
Dim sngElapsedTime As Single
sngElapsedTime = Timer – sngStartTime
Select Case sngElapsedTime
Case Is > (intMinutesUntilShutDown * conSecondsPerMinute)
‘MsgBox “QUIT”
Case Is > ((intMinutesUntilShutDown – intMinutesWarningAppears) * conSecondsPerMinute)
‘* Make the warning form visible
Me.Visible = True
Case Else
‘* The next line can be commented out if the form is opened hidden
‘Me.Visible = False
End Select
End SubOn your common user form, add the following event procedures for the specific control:
Private Sub txtSpecific_KeyPress(KeyAscii As Integer)
sngStartTime = Timer
End SubPrivate Sub txtSpecific_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
sngStartTime = Timer
End Subwhere txtSpecific is the name of the control; these event procedures resets the time.
-
WSHansV
AskWoody LoungerDecember 4, 2003 at 10:23 pm #753127You would have to move the declaration of sngStartTime to a standard module:
Public sngStartTime As Single
The Form_Timer routine of the hidden form can be simplified to
Private Sub Form_Timer()
Dim sngElapsedTime As Single
sngElapsedTime = Timer – sngStartTime
Select Case sngElapsedTime
Case Is > (intMinutesUntilShutDown * conSecondsPerMinute)
‘MsgBox “QUIT”
Case Is > ((intMinutesUntilShutDown – intMinutesWarningAppears) * conSecondsPerMinute)
‘* Make the warning form visible
Me.Visible = True
Case Else
‘* The next line can be commented out if the form is opened hidden
‘Me.Visible = False
End Select
End SubOn your common user form, add the following event procedures for the specific control:
Private Sub txtSpecific_KeyPress(KeyAscii As Integer)
sngStartTime = Timer
End SubPrivate Sub txtSpecific_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
sngStartTime = Timer
End Subwhere txtSpecific is the name of the control; these event procedures resets the time.
-
-
WSgrozy
AskWoody LoungerDecember 4, 2003 at 2:43 pm #752893I’ve narrowed it down to one specific control on a user common form that I’d like to prevent the shutdown from occuring if keypress or mousemove. Could you provide an example of an event handler which would reset the time established on my inactive form shutown(provided in earlier post). Thanks.
-
-
WSHansV
AskWoody LoungerDecember 4, 2003 at 1:42 pm #752860Microsoft provides a simplistic example of detecting if the user moves to another control or form in HOW TO: Detect User Idle Time or Inactivity in Access 2000.
But if you would like to detect mouse moves (and keystrokes), you would have to create event handlers for all forms and all their controls. And reports don’t have On MouseDown or On KeyPress events…
-
WSSupport4John
AskWoody LoungerDecember 4, 2003 at 11:59 pm #753151Hi
You may want to take a look at the following for an example:
http://www.RogersAccesslibrary.com[/url%5D , LogUsersOffNonUse.mdb
You can place the Call UpdateActivity at any control of your choice.
HTH
John
-
WSSupport4John
AskWoody LoungerDecember 4, 2003 at 11:59 pm #753152Hi
You may want to take a look at the following for an example:
http://www.RogersAccesslibrary.com[/url%5D , LogUsersOffNonUse.mdb
You can place the Call UpdateActivity at any control of your choice.
HTH
John
Viewing 5 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
MS Office 365 Home on MAC
by
MickIver
1 hour, 15 minutes ago -
search by picture an not all that’s cracked up to be (Awaiting moderation)
by
Dru Fuksa
6 hours, 12 minutes ago -
Google’s Veo3 video generator. Before you ask: yes, everything is AI here
by
Alex5723
13 hours, 18 minutes ago -
Flash Drive Eject Error for Still In Use
by
J9438
14 hours, 51 minutes ago -
Windows 11 Insider Preview build 27863 released to Canary
by
joep517
1 day, 8 hours ago -
Windows 11 Insider Preview build 26120.4161 (24H2) released to BETA
by
joep517
1 day, 8 hours ago -
AI model turns to blackmail when engineers try to take it offline
by
Cybertooth
11 hours, 50 minutes ago -
Migrate off MS365 to Apple Products
by
dmt_3904
12 hours, 39 minutes ago -
Login screen icon
by
CWBillow
3 hours, 1 minute ago -
AI coming to everything
by
Susan Bradley
10 hours, 37 minutes ago -
Mozilla : Pocket shuts down July 8, 2025, Fakespot shuts down on July 1, 2025
by
Alex5723
1 day, 23 hours ago -
No Screen TurnOff???
by
CWBillow
2 days ago -
Identify a dynamic range to then be used in another formula
by
BigDaddy07
2 days ago -
InfoStealer Malware Data Breach Exposed 184 Million Logins and Passwords
by
Alex5723
2 days, 12 hours ago -
How well does your browser block trackers?
by
n0ads
1 day, 22 hours ago -
You can’t handle me
by
Susan Bradley
22 hours, 37 minutes ago -
Chrome Can Now Change Your Weak Passwords for You
by
Alex5723
1 day, 15 hours ago -
Microsoft: Over 394,000 Windows PCs infected by Lumma malware, affects Chrome..
by
Alex5723
2 days, 23 hours ago -
Signal vs Microsoft’s Recall ; By Default, Signal Doesn’t Recall
by
Alex5723
2 days, 3 hours ago -
Internet Archive : This is where all of The Internet is stored
by
Alex5723
3 days ago -
iPhone 7 Plus and the iPhone 8 on Vantage list
by
Alex5723
3 days ago -
Lumma malware takedown
by
EyesOnWindows
2 days, 12 hours ago -
“kill switches” found in Chinese made power inverters
by
Alex5723
3 days, 9 hours ago -
Windows 11 – InControl vs pausing Windows updates
by
Kathy Stevens
3 days, 8 hours ago -
Meet Gemini in Chrome
by
Alex5723
3 days, 13 hours ago -
DuckDuckGo’s Duck.ai added GPT-4o mini
by
Alex5723
3 days, 13 hours ago -
Trump signs Take It Down Act
by
Alex5723
3 days, 21 hours ago -
Do you have a maintenance window?
by
Susan Bradley
2 days, 1 hour ago -
Freshly discovered bug in OpenPGP.js undermines whole point of encrypted comms
by
Nibbled To Death By Ducks
2 days, 23 hours ago -
Cox Communications and Charter Communications to merge
by
not so anon
4 days ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.