Question : auto log off and close forms if idle problem

Hi with loads of help from EE I have made a system that after stated time and no use of database it brings up a pop up that counts down 60 seconds then after that shuts down ALL forms and then reopens the login form.
The code that detects for 'idle' is on the Switchboard as this form is always open even when you open other forms the switchboard remains in the background.
THE PROBLEM:
the code is only detecting for 'idle' on the Switchboard form its self "frmGENSwitchboard"
so if you are working on any other form within the database and have not touched the "frmGENSwitchboard" from then this still counts as 'idle' (non use) and logs out the user.
I NEED:
the code in the switchboard to detect any use on any form that is open and only if no use of entire database then it follows the comand.

I have copied the code below that detects 'idle' that is in the "frmGENSwitchboard" also please note that the timer interval on this form is set to 1000.
CAN YOU HELP?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
Sub Form_Timer()
   ' IDLEMINUTES determines how much idle time to wait for before
   ' running the IdleTimeDetected subroutine.
   Const IDLEMINUTES = 1
 
   Static PrevControlName As String
   Static PrevFormName As String
   Static ExpiredTime
 
   Dim ActiveFormName As String
   Dim ActiveControlName As String
   Dim ExpiredMinutes
 
   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 call the IdleTimeDetected subroutine.
      IdleTimeDetected ExpiredMinutes
   End If
End Sub
Sub IdleTimeDetected(ExpiredMinutes)
   Dim stDocName As String
   Dim stLinkCriteria As String
 
    stDocName = "Form1"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
 
End Sub

Answer : auto log off and close forms if idle problem

<Is this what you found?>>

 Typing is not the same thing as as moving from control to control or to another form, so yes while you are typing the clock will continue to go up.  However you should see that when you move to another control on a form outside the switch board, the count does reset.

 I don't see this as a problem, except possibly on a memo control.  It should not take you more then a few minutes to type something into a control before moving to another and resetting the clock.

 If you really want to regard typing, then you'd need to use code in every forms Keypreview event or hook the main access window and look for keyboard and mouse window messages; not a trivial task.

JimD.

Random Solutions  
 
programming4us programming4us