• Shutdown on inactiviy (Access 2K SP1)

    Author
    Topic
    #397446

    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

    Viewing 5 reply threads
    Author
    Replies
    • #752851

      You can’t do this easily. What are you trying to accomplish? By that, I mean why do you want to shut the application down, do you want to shut it down on all machines or only one that has been inactive, etc. If you provide details, we may be able to provide answers.

      • #752864

        The 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 Integer

        Private Sub Form_Close()
        On Error Resume Next
        ctlSave = Nothing
        End Sub

        Private 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 Sub

        Private 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 = Nothing

        Case 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 Sub

        Private Sub InactiveShutDownCancel_Click()
        sngStartTime = Timer
        Me.Visible = False
        End Sub

      • #752865

        The 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 Integer

        Private Sub Form_Close()
        On Error Resume Next
        ctlSave = Nothing
        End Sub

        Private 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 Sub

        Private 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 = Nothing

        Case 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 Sub

        Private Sub InactiveShutDownCancel_Click()
        sngStartTime = Timer
        Me.Visible = False
        End Sub

    • #752852

      You can’t do this easily. What are you trying to accomplish? By that, I mean why do you want to shut the application down, do you want to shut it down on all machines or only one that has been inactive, etc. If you provide details, we may be able to provide answers.

    • #752859

      Microsoft 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…

      • #752892

        I’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.

        • #753126

          You 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 Sub

          On your common user form, add the following event procedures for the specific control:

          Private Sub txtSpecific_KeyPress(KeyAscii As Integer)
          sngStartTime = Timer
          End Sub

          Private Sub txtSpecific_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
          sngStartTime = Timer
          End Sub

          where txtSpecific is the name of the control; these event procedures resets the time.

        • #753127

          You 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 Sub

          On your common user form, add the following event procedures for the specific control:

          Private Sub txtSpecific_KeyPress(KeyAscii As Integer)
          sngStartTime = Timer
          End Sub

          Private Sub txtSpecific_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
          sngStartTime = Timer
          End Sub

          where txtSpecific is the name of the control; these event procedures resets the time.

      • #752893

        I’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.

    • #752860

      Microsoft 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…

    • #753151

      Hi

      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

    • #753152

      Hi

      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
    Reply To: Shutdown on inactiviy (Access 2K SP1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: