Jim Dettman
jimdettman at verizon.net
Thu May 3 08:40:53 CDT 2007
Lambert, Here's the one your thinking about: HOW TO: Detect User Idle Time or Inactivity in Access 2000 http://support.microsoft.com/kb/210297 Jim. -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Heenan, Lambert Sent: Thursday, May 03, 2007 9:26 AM To: 'Access Developers discussion and problem solving' Cc: 'fuller.artful at gmail.com' Subject: Re: [AccessD] Lock-screen inside an Access app This is quite simple to do and was laid out in some Kb article or other that I read years ago. Because most Access applications are interactive, you don't need to worry about tracking keystrokes or mouse movements. Instead you just need to watch what forms, and controls within those forms are currently active, and this is made very easy by using the Screen object. You can use its ActiveForm and ActiveControl properties to keep tabs on where the user is. This is all done inside a form that you open as hidden, and it has a timer event that checks the user activity. In my apps I simply kick inactive users out, but you could just as easily pop up a modal form that demands a password. Below is the essential code you need in the forms timer event. No need at all for class wrappers and sinking mouse events. HTH Lambert Private Sub Form_Timer() Const IDLEMINUTES = 30 Static PrevControlName As String Static PrevFormName As String Static ExpiredTime As Long Dim ActiveFormName As String Dim ActiveControlName As String Dim ExpiredMinutes As Long On Error Resume Next ' Get the active form and control name. ActiveFormName = Screen.ActiveForm.Name If Err Then ActiveFormName = "No Active Form" Err = 0 End If ActiveControlName = Screen.ActiveControl.Name If Err Then ActiveControlName = "No Active Control" Err = 0 End If ' Record the current active names and reset ExpiredTime if: ' 1. They have not been recorded yet (code is running ' for the first time). ' 2. The previous names are different than the current ones ' (the user has done something different during the timer ' interval). If (PrevControlName = "") Or (PrevFormName = "") _ Or (ActiveFormName <> PrevFormName) _ Or (ActiveControlName <> PrevControlName) Then PrevControlName = ActiveControlName PrevFormName = ActiveFormName ExpiredTime = 0 Else ' ...otherwise the user was idle during the time interval, so ' increment the total expired time. ExpiredTime = ExpiredTime + Me.TimerInterval End If ' Does the total expired time exceed the IDLEMINUTES? ExpiredMinutes = (ExpiredTime / 1000) / 60 If ExpiredMinutes >= IDLEMINUTES Then ' ...if so, then reset the expired time to zero... ExpiredTime = 0 ' AND HERE DO WHATEVER YOU NEED TO DO WHEN A USER HAS ' NOT DONE ANYTHING FOR THE DEFINED IDLEMINUTE PERIOD End If End Sub -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller Sent: Thursday, May 03, 2007 7:53 AM To: Access Developers discussion and problem solving Subject: [AccessD] Lock-screen inside an Access app A friend asked me how he could put a Windows-like screen lock (that asks for a password) inside an Access app. He's thinking that it's a hidden form that then appears after x minutes of inactivity and wants a password before letting the user back into the app. Presumably it would shut the app down with no valid password. Does anyone have an idea how to do this? TIA, Arthur -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com