Results 1 to 13 of 13
  1. #1
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Redditch, Worcestershire, England
    Posts
    233
    Thanks
    0
    Thanked 22 Times in 21 Posts

    Enforcing time-out in editing form (Access 2000)

    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

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

    Re: Enforcing time-out in editing form (Access 2000)

    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.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Richland, Washington, USA
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enforcing time-out in editing form (Access 2000)

    Check out using the form's On Timer event.

    Hope this helps.

  4. #4
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Redditch, Worcestershire, England
    Posts
    233
    Thanks
    0
    Thanked 22 Times in 21 Posts

    Re: Enforcing time-out in editing form (Access 2000)

    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

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

    Re: Enforcing time-out in editing form (Access 2000)

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

  6. #6
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enforcing time-out in editing form (Access 200

    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.

  7. #7
    2 Star Lounger
    Join Date
    Mar 2004
    Location
    Cincinnati, Ohio, USA
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enforcing time-out in editing form (Access 200

    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.

  8. #8
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enforcing time-out in editing form (Access 200

    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

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

    Re: Enforcing time-out in editing form (Access 200

    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.

  10. #10
    2 Star Lounger
    Join Date
    Mar 2004
    Location
    Cincinnati, Ohio, USA
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enforcing time-out in editing form (Access 200

    Or

    DoCmd.Quit Options:=acQuitSaveNone

    Either way, the cat is skinned.

  11. #11
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enforcing time-out in editing form (Access 200

    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?

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

    Re: Enforcing time-out in editing form (Access 200

    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.

  13. #13
    2 Star Lounger
    Join Date
    Mar 2004
    Location
    Cincinnati, Ohio, USA
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enforcing time-out in editing form (Access 200

    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.

    <pre>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
    </pre>


Posting Permissions

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