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, 4 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
-
WARNING about Nvidia driver version 572.83 and 4000/5000 series cards
by
Bob99
22 minutes ago -
Creating an Index in Word 365
by
CWBillow
10 hours, 46 minutes ago -
Coming at Word 365 and Table of Contents
by
CWBillow
10 hours, 51 minutes ago -
Windows 11 Insider Preview Build 22635.5170 (23H2) released to BETA
by
joep517
15 hours, 47 minutes ago -
Has the Microsoft Account Sharing Problem Been Fixed?
by
jknauth
19 hours, 12 minutes ago -
W11 24H2 – Susan Bradley
by
G Pickerell
21 hours, 8 minutes ago -
7 tips to get the most out of Windows 11
by
Alex5723
19 hours, 9 minutes ago -
Using Office apps with non-Microsoft cloud services
by
Peter Deegan
12 hours, 31 minutes ago -
I installed Windows 11 24H2
by
Will Fastie
1 hour, 11 minutes ago -
NotifyIcons — Put that System tray to work!
by
Deanna McElveen
1 day ago -
Decisions to be made before moving to Windows 11
by
Susan Bradley
6 minutes ago -
Port of Seattle says ransomware breach impacts 90,000 people
by
Nibbled To Death By Ducks
1 day, 8 hours ago -
Looking for personal finance software with budgeting capabilities
by
cellsee6
17 hours, 2 minutes ago -
ATT/Yahoo Secure Mail Key
by
Lil88reb
17 hours, 17 minutes ago -
Devices with apps using sprotect.sys driver might stop responding
by
Alex5723
2 days, 1 hour ago -
Neowin – 20 times computers embarrassed themselves with public BSODs and goofups
by
EP
2 days, 10 hours ago -
Slow Down in Windows 10 performance after March 2025 updates ??
by
arbrich
1 day, 12 hours ago -
Mail from certain domains not delivered to my outlook.com address
by
pumphouse
1 day, 18 hours ago -
Is data that is in OneDrive also taking up space on my computer?
by
WShollis1818
2 days, 5 hours ago -
Nvidia just fixed an AMD Linux bug
by
Alex5723
3 days, 21 hours ago -
50 years and counting
by
Susan Bradley
19 hours, 27 minutes ago -
Fix Bluetooth Device Failed to Delete in Windows Settings
by
Drcard:))
22 hours, 16 minutes ago -
Licensing and pricing updates for on-premises server products coming July 2025
by
Alex5723
4 days, 8 hours ago -
Edge : Deprecating window.external.getHostEnvironmentValue()
by
Alex5723
4 days, 8 hours ago -
Rethinking Extension Data Consent: Clarity, Consistency, and Control
by
Alex5723
4 days, 8 hours ago -
OneNote and MS Word 365
by
CWBillow
4 days, 10 hours ago -
Ultimate Mac Buyers Guide 2025: Which Mac is Right For You?
by
Alex5723
4 days, 10 hours ago -
Intel Unison support ends on Windows 11 in June
by
Alex5723
4 days, 10 hours ago -
April 2025 — still issues with AMD + 24H2
by
Kevin Jones
2 days, 2 hours ago -
Windows 11 Insider Preview build 26200.5518 released to DEV
by
joep517
4 days, 22 hours 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.