• Enforcing time-out in editing form (Access 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Enforcing time-out in editing form (Access 2000)

    Author
    Topic
    #388886

    I am currently putting together a project in Access 2000 that will involve a front-end / back-end combination of databases, and my user population consists of the sort of people who will happily start to edit a record and then wander off to do other more interesting things!

    I’m thinking it would be a good idea to “time them out” if they start editing within a form and then leave it “dirty” for an extended period of time. Can anyone suggest a good approach to doing this? Would the technique need to be different if the back end were SQL Server rather than Access at some point in the future?

    Thanks

    Jeremy

    Viewing 1 reply thread
    Author
    Replies
    • #684589

      See HOW TO: Detect User Idle Time or Inactivity in Access 2000. The code there just puts up a message box, but you can substitute another action – saving the record, closing the form, …

      Since the code uses a form, it will work with a SQL Server backend as well.

      • #1031894

        Hi Hans,

        I implemented the code in the link you provided. But I had a few questions…

        1. I’m using the automatic close

        Sub IdleTimeDetected(ExpiredMinutes)
        Application.Quit acSaveYes
        End Sub

        Is it possible to display a popup message and still automaticall close a few seconds after. For example, we have detected Inactivity, this application will automatically close in one minute? Additionally, I have set my db to automatically compact and repair on exit, does this still occur if it shuts down like so? As always, thank you for any input.

        • #1031897

          How do you intend to display your warning message? If you are intending to use a MsgBox call, please don’t. Your code will tend to be interrupted until the user clicks OK to close the message box.

          You are better off displaying a form with the message appearing on it.

          Any particular reason that a user would be saving things when closing out of the application? In general my users don’t save any objects in my applications. The only changes they make to forms are modifications to filters. Typically those don’t need to be saved.

          • #1031901

            I just used the example from the Microsoft site. You’re correct, they will not be saving. They simply use the app to view reports and utilize forms to edit and add data. As a result, should I just use the following instead:

            Application.Quit

            Instead of Application.Quit acSaveYes

            • #1031903

              I’d use

              Application.Quit acQuitSaveNone

              to make sure that the user doesn’t get prompted to save any database objects that might have changed. (Records that have been changed will still be saved automatically)

              I agree with Mike that you should display a form instead of using MsgBox if you want to show a message. MsgBox will pause all code until the user clicks a button.

            • #1031935

              Thank you for the replies. So I added the form.

              Sub IdleTimeDetected(ExpiredMinutes)
              DoCmd.OpenForm “frmWarning”
              End Sub

              But is it possible to have it display for a minute then automatically shut down if nothing is detected?

            • #1031937

              Set the TimerInterval property of the frmWarning form to 60000 (milliseconds)
              Put code in the On Timer event of this form:

              Private Form_Timer()
              ‘ your code goes here, e.g. to close the form:
              DoCmd.Close acForm, Me.Name, acSaveNo
              ‘ or to quit Access:
              Application.Quit acQuitSaveNone
              End Sub

              The code in the On Timer event procedure will be executed every TimerInterval milliseconds. Since you close the form or quit Access, it’ll be executed only once in this situation.

            • #1031941

              If my not-so-vivid imagination, your warning form was going to stay open for a very brief period and then close itself….or get closed when the terminating routine is called.

              Elsewhere, like maybe embedded in your MainMenu, switchboard, etc. is a ShutdownIfUserIsLazy routine that is called periodically. It checks to see how long your user has been latent. If the inactivity period exceeds your tolerance, the ShutdownIfUserIsLazy closes the application.

              Whenever a user does something, like makes a form dirty (edits data), the LASTACTION will need to be updated.

              Public Const  WARNINGTIME as Integer = 55
              Public Const  HASTALAVISTA as Integer = 60
              Public LASTACTION as Date
              
              Public Sub UpdateMyTimer()
                        LASTACTION = VBA.Now()
              End Sub
              
              
              Public Sub ShutdownIfUserIsLazy ()
              On Error goto Err_ShutdownIfUserIsLazy 
              
                       Dim dtLatency as Date
              
                       dtLatency = VBA.DateDiff("n", VBA.Now(), LASTACTION)
              
                       if dtLatency = WARNINGTIME then Call ShowWarning()
                       if dtLatency >= HASTALAVISTA then DoCmd.Quit
              
              Exit_ShutdownIfUserIsLazy :
                       Exit Sub
              
              Err_ShutdownIfUserIsLazy :
                       Call ErrHandler(.....)
                       Resume Exit_ShutdownIfUserIsLazy 
              
              End Sub         
              
            • #1031905

              Or

              DoCmd.Quit Options:=acQuitSaveNone

              Either way, the cat is skinned.

    • #684590

      Check out using the form’s On Timer event.

      Hope this helps.

      • #684894

        Thanks for the suggestions. It’s really only in the editing form part of the application that I want to trigger this.
        I realised I’d have to use a Timer somewhere, but what I’m stuck on are the following 2 questions:
        (i) how do I tell when the user starts any sort of edit in the form (as opposed to beginning to update a given field)?
        (ii) how do I capture when the current record is saved (i.e. the form is no longer in edit mode) – where’s the best place to try to trap this?

        Thanks

        Jeremy

        • #684906

          (i) You could set a flag in the OnChange event of a text box or combo box, and clear the flag in the AfterUpdate event. That way, you can keep track of the “being edited” status.
          (ii) The Dirty property of a form indicates whether the current record has been changed since the last save, i.e. if the form is in edit mode.

    Viewing 1 reply thread
    Reply To: Enforcing time-out in editing form (Access 2000)

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

    Your information: