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, but widespread attacks make patching prudent. Go ahead and patch, but watch out for potential problems. |
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
-
Steps to take before updating to 24H2
by
Susan Bradley
1 hour, 41 minutes ago -
Which Web browser is the most secure for 2025?
by
B. Livingston
2 hours, 4 minutes ago -
Replacing Skype
by
Peter Deegan
55 seconds ago -
FileOptimizer — Over 90 tools working together to squish your files
by
Deanna McElveen
1 hour, 31 minutes ago -
Excel Macro — ask for filename to be saved
by
nhsj
10 hours, 20 minutes ago -
Trying to backup Win 10 computer to iCloud
by
SheltieMom
1 day, 7 hours ago -
Windows 11 Insider Preview build 26200.5570 released to DEV
by
joep517
1 day, 21 hours ago -
Windows 11 Insider Preview build 26120.3941 (24H2) released to BETA
by
joep517
1 day, 23 hours ago -
Windows 11 Insider Preview Build 22635.5305 (23H2) released to BETA
by
joep517
1 day, 23 hours ago -
No April cumulative update for Win 11 23H2?
by
Peobody
11 hours, 1 minute ago -
AugLoop.All (TEST Augmentation Loop MSIT)
by
LarryK
1 day, 23 hours ago -
Boot Sequence for Dell Optiplex 7070 Tower
by
Serge Carniol
2 days, 14 hours ago -
OTT Upgrade Windows 11 to 24H2 on Unsupported Hardware
by
bbearren
2 days, 18 hours ago -
Inetpub can be tricked
by
Susan Bradley
1 day, 1 hour ago -
How merge Outlook 2016 .pst file w/into newly created Outlook 2024 install .pst?
by
Tex265
1 day, 12 hours ago -
FBI 2024 Internet Crime Report
by
Alex5723
2 days, 21 hours ago -
Perplexity CEO says its browser will track everything users do online
by
Alex5723
7 hours, 2 minutes ago -
Login issues with Windows Hello
by
CWBillow
3 days, 9 hours ago -
How to get into a manual setup screen in 2024 Outlook classic?
by
Tex265
2 days, 20 hours ago -
Linux : ARMO rootkit “Curing”
by
Alex5723
3 days, 20 hours ago -
Employee monitoring app leaks 21 million screenshots in real time
by
Alex5723
3 days, 20 hours ago -
Google AI is now hallucinating idioms
by
Alex5723
3 days, 21 hours ago -
april update
by
69800
2 days, 1 hour ago -
Windows 11 Insider Preview build 27842 released to Canary
by
joep517
3 days, 22 hours ago -
Quick Fix for Slowing File Explorer
by
Drcard:))
3 days, 22 hours ago -
WuMgr not loading?
by
LHiggins
2 days, 18 hours ago -
Word crashes when accessing Help
by
CWBillow
8 hours, 17 minutes ago -
New Microsoft Nag — Danger! Danger! sign-in to your Microsoft Account
by
EricB
3 days, 21 hours ago -
Blank Inetpub folder
by
Susan Bradley
3 days, 19 hours ago -
Google : Extended Repair Program for Pixel 7a
by
Alex5723
4 days, 8 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.