Time out on form - automatically close a form if no activity

Posted on 2004-11-11
Last Modified: 2012-06-27
I have a load of users that leave an inputting screen open, rather than close it and return to the front form.

Is it possible (!) to have a timer running on the open form that checks to see if a certain field is null, say every 3 minutes, and if it is null will force that form to close - maybe even ignorning any errors that might occur as a result of forcing a form to close, such as part completing a record..?  Not bothered about keeping changes to a part-completed record.


Question by:Lapchien
    LVL 14

    Expert Comment

    you can use the OnTimer event of the form and set the interval to 3 minutes


    Author Comment

    yes - but what would the code be to check if a field is null, something like

    if isnull (me.myfield) then

    drop anything input on the form (don't know the code for this)




    What is the timer interval for 3 minutes?
    LVL 14

    Expert Comment

    actually, what i would do is first to save the record with the code Me.Refresh (and use an error handler with "resume next" to catch any errors), then close the form with this code

      DoCmd.Close acForm, "MyForm", acSaveNo

    (this ignores all design changes, if any were done; sometimes access thinks someone has changed the design even though this wasn't really the case, probably when filters are set or similar).

    LVL 14

    Accepted Solution

    ok, before you do the refresh (i mentioned before) you should do the null check:

    sub form_ontimer

      on error goto err_handler

      if isnull ( me.myfield ) then
        me.myfield = "default value"
      end if


      DoCmd.Close acForm, "MyForm", acSaveNo

        resume next

    end sub

    the timer interval must be given in milliseconds, so it's 180000  (3min x 60secs x 1000) for 3 minutes.


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now