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, 6 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 #752852WSHansV
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
-
National scam day
by
Susan Bradley
21 minutes ago -
macOS Tahoe 26 the end of the road for Intel Macs, OCLP, Hackintosh
by
Alex5723
2 hours, 33 minutes ago -
Cyberattack on some Washington Post journalists’ email accounts
by
Bob99
3 hours, 53 minutes ago -
Tools to support internet discussions
by
Kathy Stevens
10 hours, 43 minutes ago -
How get Group Policy to allow specific Driver to download?
by
Tex265
9 hours, 3 minutes ago -
AI is good sometimes
by
Susan Bradley
11 hours, 5 minutes ago -
Mozilla quietly tests Perplexity AI as a New Firefox Search Option
by
Alex5723
1 hour, 8 minutes ago -
Perplexity Pro free for 12 mos for Samsung Galaxy phones
by
Patricia Grace
1 day, 11 hours ago -
June KB5060842 update broke DHCP server service
by
Alex5723
1 day, 9 hours ago -
AMD Ryzen™ Chipset Driver Release Notes 7.06.02.123
by
Alex5723
1 day, 13 hours ago -
Excessive security alerts
by
WSSebastian42
4 hours, 44 minutes ago -
* CrystalDiskMark may shorten SSD/USB Memory life
by
Alex5723
1 day, 23 hours ago -
Ben’s excellent adventure with Linux
by
Ben Myers
41 minutes ago -
Seconds are back in Windows 10!
by
Susan Bradley
1 day, 10 hours ago -
WebBrowserPassView — Take inventory of your stored passwords
by
Deanna McElveen
4 hours, 11 minutes ago -
OS news from WWDC 2025
by
Will Fastie
14 hours, 30 minutes ago -
Need help with graphics…
by
WSBatBytes
18 hours, 44 minutes ago -
AMD : Out of Bounds (OOB) read vulnerability in TPM 2.0 CVE-2025-2884
by
Alex5723
2 days, 14 hours ago -
Totally remove or disable BitLocker
by
CWBillow
1 day, 14 hours ago -
Windows 10 gets 6 years of ESU?
by
n0ads
1 day, 17 hours ago -
Apple, Google stores still offer China-based VPNs, report says
by
Nibbled To Death By Ducks
3 days, 1 hour ago -
Search Forums only bring up my posts?
by
Deo
10 hours, 18 minutes ago -
Windows Spotlight broken on Enterprise and Pro for Workstations?
by
steeviebops
3 days, 13 hours ago -
Denmark wants to dump Microsoft for Linux + LibreOffice
by
Alex5723
3 days, 5 hours ago -
How to get Microsoft Defender to honor Group Policy Setting
by
Ralph
3 days, 13 hours ago -
Apple : Paragon’s iOS Mercenary Spyware Finds Journalists Target
by
Alex5723
4 days ago -
Music : The Rose Room – It’s Been A Long, Long Time album
by
Alex5723
4 days, 1 hour ago -
Disengage Bitlocker
by
CWBillow
3 days, 15 hours ago -
Mac Mini M2 Service Program for No Power Issue
by
Alex5723
4 days, 3 hours ago -
New Win 11 Pro Geekom Setup questions
by
Deo
10 hours, 6 minutes 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.