• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

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.

Thanks
Lapchien

0
Lapchien
Asked:
Lapchien
  • 3
1 Solution
 
bluelizardCommented:
you can use the OnTimer event of the form and set the interval to 3 minutes


--bluelizard
0
 
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)

then

docmd.close

?

What is the timer interval for 3 minutes?
0
 
bluelizardCommented:
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).


--bluelizard
0
 
bluelizardCommented:
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

  me.refresh

  DoCmd.Close acForm, "MyForm", acSaveNo

  err_handler:
    resume next

end sub


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


--bluelizard
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now