I have timer on two forms.
1) login form (after user logs in -- this is hidden but not closed)
2) Dashboard (on top right corner it shows, count down time, but on activity time restarts)
code on timer is below
Timer interval is 1000
Both forms have same code, except login form wont show count down. What do you think, if I run the will it always flicker unless no timer?
1) login form (after user logs in -- this is hidden but not closed)
2) Dashboard (on top right corner it shows, count down time, but on activity time restarts)
code on timer is below
Timer interval is 1000
Both forms have same code, except login form wont show count down. What do you think, if I run the will it always flicker unless no timer?
Code:
Private Sub Form_Timer()
Const IDLEMINUTES = 20
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
If (PrevControlName = "") Or (PrevFormName = "") _
Or (ActiveFormName <> PrevFormName) _
Or (ActiveControlName <> PrevControlName) Then
PrevControlName = ActiveControlName
PrevFormName = ActiveFormName
ExpiredTime = 0
Else
ExpiredTime = ExpiredTime + Me.TimerInterval
End If
' Does the total expired time exceed the IDLEMINUTES?
ExpiredMinutes = (ExpiredTime / 1000) / 60
Me.txtIdleTime = ExpiredMinutes
'here above Me.txtIdleTime is my control on form, which shows count down time.
If ExpiredMinutes >= IDLEMINUTES Then
ExpiredTime = 0
IdleTimeDetected ExpiredMinutes
End If
End Sub