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

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.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

LapchienDirectorAuthor Commented:
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?
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).

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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.