Dale_Fye,
Thanks for the message. However, after following the steps, when I tried to
open the form, I get the following error:
The expression on timer you entered in the event property setting produced
the following error: User defined typed not declared.
Do I need to check off any thing in the reference library, if so, what?
Thanks
"Dale_Fye via AccessMonster.com" wrote:
> It depends on how you define no activity. Personally, I consider no activity
> to mean that no information has been entered in the form, that the cursor has
> not moved out of its original location, and that the mouse has not moved.
>
> To do something like this you need to:
>
> 1. Set the forms KeyPreview property to Yes
> 2. Declare a DateTime variable at the form level (in the forms declaration
> section)
>
> Dim dtLastActivity as date
>
> 3. Put some code in the forms KeyDown and MouseMove events to reset
> dtLastActivity
>
> Private Sub Form_KeyDown
>
> dtLastActivity = Now()
>
> End sub
>
> 5. Set the Forms TimerInterval to 10000 (checks every 10 seconds) and then
> add code to the forms Timer event to determine whether more than 5 minutes
> has elapsed since dtLastActivity.
>
> Private Sub Form_Timer
>
> if datediff("s", dtLastActivity, Now()) > 300 then
> me.undo
> docmd.close acform, me.name
> endif
> End Sub
>
> You could also through some code in the Timer event to write any changes that
> have occurred to your data before closing the form. The problem with this is
> that if you have made changes, and those changes do not pass your validation
> checks, then you would also have to add some code whereever you are doing
> those checks, to bypass those checks, or if the checks were failed, then undo
> them.
>
> Additionally, I mentioned that I would use the forms MouseMove event to reset
> the dtLastActivity. If the controls on your form are too close together,
> then the forms MouseMove event may not fire, in which case you might have to
> use the MouseMove events that are associated with some of the controls on
> your form as well.
>
> HTH
> Dale
> Armele wrote:
> >Hi,
> >
> >I would like a form to be closed if there is no activity after 5 minutes.
> >How do I code it?
>
> --
> HTH
>
> Dale Fye
>
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/For...dules/200906/1
>
>