This post is a solution that my users have been testing for several days and it seems to work. It is being posted in case others are searching for an example. The Access application is running on Citrix. Sometimes people close the wireless PC and the Access session is still running on Citrix. Due to business rules, some forms will not allow an exit unless all requirements are completed. For that reason, this code does not hard force the Access application to quit.
After 2 hours of user idle, it notifies the user to close. From there, it reminds the user every 1 min.
The code is on a Splash Screen (first screen to open) that persist the linked tables during the session. There is one hidden textActive on the splash screen. The Timer Interval is set to 12000
If this code was helpful, a thanks would be appreciatedPrivate Sub Form_Timer() ' Rx_ 10/8/2011 -- After 120 minutes of idle - warn user then warn every 60 seconds Const c_intIDLEMINUTES = 120 '120 ' lower number for testing Const c_intIDLEMINUTES2 = 1# '30 ' after evaluation - asked to change to 1 min Static strPrevCtlName As String Static strPrevFrmName As String Static lngExpiredTime As Long Dim strActiveFrmName As String Dim strActiveCtlName As String Dim lngExpiredMinutes As Long Dim txtmsgboxTitle As String Dim txtmsgboxMessage As String txtmsgboxTitle = "Regulatory Database Inactivity Warning" txtmsgboxMessage = "Complete any data entry and close the current database session. " & vbNewLine & "A new session can be initiated immediately after closure." 10 On Error Resume Next 20 If Not IdleTimeExceeded Then 30 strActiveFrmName = Screen.ActiveForm.Name 40 If Err Then 50 strActiveFrmName = "No Active Form" 60 Err = 0 70 End If 80 strActiveCtlName = Screen.ActiveControl.Name 90 If Err Then 100 strActiveCtlName = "No Active Control" 110 Err = 0 120 End If 130 txtActive.Text = strActiveCtlName & ";" & strActiveFrmName 140 If (strPrevCtlName = "") Or (strPrevFrmName = "") Or (strActiveFrmName <> strPrevFrmName) Or (strActiveCtlName <> strPrevCtlName) Then 150 strPrevCtlName = strActiveCtlName 160 strPrevFrmName = strActiveFrmName 170 lngExpiredTime = 0 180 Else 190 lngExpiredTime = lngExpiredTime + Me.TimerInterval 200 End If 210 lngExpiredMinutes = (lngExpiredTime / 1000) / 60 220 If lngExpiredMinutes >= c_intIDLEMINUTES Then 230 lngExpiredTime = 0 240 MsgBox txtmsgboxMessage, vbOKOnly + vbCritical + vbSystemModal, txtmsgboxTitle 250 IdleTimeExceeded = True ' once exceeded - change to new schedule 260 End If 270 Else 280 lngExpiredTime = lngExpiredTime + Me.TimerInterval 290 lngExpiredMinutes = (lngExpiredTime / 1000) / 60 300 If lngExpiredMinutes >= c_intIDLEMINUTES2 Then 310 lngExpiredTime = 0 320 MsgBox txtmsgboxMessage, vbOKOnly + vbCritical + vbSystemModal, txtmsgboxTitle 'Application.Quit acQuitSaveAll ' <--- action here may not work (or loose data) if some forms have required fields before form_close 330 End If 340 End If End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks