PC Review


Reply
Thread Tools Rate Thread

Adding time on a form

 
 
Armele
Guest
Posts: n/a
 
      25th Jun 2009

Hi,

I would like a form to be closed if there is no activity after 5 minutes.
How do I code it?
 
Reply With Quote
 
 
 
 
Armele
Guest
Posts: n/a
 
      25th Jun 2009

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

 
Reply With Quote
 
Armele
Guest
Posts: n/a
 
      25th Jun 2009

I am still getting the same error.

"Dale_Fye via AccessMonster.com" wrote:

> My guess is that you did not put the declaration of dtLastActivity in the
> forms declarations section.
>
> When you open that forms code, go to the very top. You should see something
> like:
>
> Option Compare Database
> Option Explicit
>
> Does not have to include both of these but I always include the Option
> Explicit line.
>
> Right below that, declare the dtLastActivity variable as DateTime, like:
>
> Private dtLastActivity as Date
>
> Below that, you should see the code for your various form and control events.
>
> Dale
>
> Armele wrote:
> >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
> >
> >> 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

> >[quoted text clipped - 48 lines]
> >> >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
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding an image to a form in run time vinceg Microsoft Access Forms 9 29th Apr 2010 02:34 PM
Run time error adding controls to form programatically ROBW Microsoft Excel Programming 0 18th Mar 2010 12:29 PM
adding time and date to a control on a form =?Utf-8?B?UVNT?= Microsoft Access Form Coding 3 7th Jun 2007 04:53 PM
Adding one time from each record together, on a continuios form =?Utf-8?B?Um9ieQ==?= Microsoft Access Form Coding 3 22nd Oct 2006 06:15 AM
Elapsed Time for Productivity / Adding back time for Lunch Breaks =?Utf-8?B?RXJpY1RleA==?= Microsoft Access VBA Modules 1 1st Feb 2005 04:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:55 AM.