Results 1 to 8 of 8
  1. #1
    Star Lounger
    Join Date
    Apr 2003
    Location
    Washington, District Of Columbia, USA
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Shutdown on inactiviy (Access 2K SP1)

    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

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Shutdown on inactiviy (Access 2K SP1)

    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.
    Charlotte

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Shutdown on inactiviy (Access 2K SP1)

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

  4. #4
    Star Lounger
    Join Date
    Apr 2003
    Location
    Washington, District Of Columbia, USA
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Shutdown on inactiviy (Access 2K SP1)

    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

  5. #5
    Star Lounger
    Join Date
    Apr 2003
    Location
    Washington, District Of Columbia, USA
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Shutdown on inactiviy (Access 2K SP1)

    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.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Shutdown on inactiviy (Access 2K SP1)

    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.

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Shutdown on inactiviy (Access 2K SP1)

    Hi

    You may want to take a look at the following for an example:

    http://www.RogersAccesslibrary.com , LogUsersOffNonUse.mdb

    You can place the Call UpdateActivity at any control of your choice.

    HTH

    John

  8. #8
    Star Lounger
    Join Date
    Apr 2003
    Location
    Washington, District Of Columbia, USA
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Shutdown on inactiviy (Access 2K SP1)

    Hans, thanks works like a champ.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •