timer event question

belsha

Registered User.
Local time
Today, 17:11
Joined
Jul 5, 2002
Messages
115
In the thread "timing an event " it was discussed how to time how long a person played snooker and figure their total time. My question is if I have a form and want to start a timer when the person begins to enter and end it when they exit the form, then send the record number and time spent entering it to a table, how would I code that? Thanks!
 
Create a hidden text box on the form (txtTime)

Set txtTime Default value = 0
Set the timer interval = 1000
Now in the on timer event place this bit of code

Me.txtTime = Me.txtTime + 1

This will increment the count by one for every second they are in the form.

Now in the onclose event of the form you can do whatever you want with Me.txtStart
 
Last edited:
Timer

Where did the txtStart come from, or is that txtTime (the hidden text box created?) On the onClose event of the form I would like to have the timer stop, the elapsed time (in the hidden text box???) to be recorded in a table (I set the control of the hidden text box to the elapsed time field in the table), and the timer reset so the next time the form starts being entered in, the process restarts. Could you please explain how to code that?
 
Sorry about the fat fingers. Disregard the txtStart..

First of all, the timer is always running, so there is no need to "stop" the timer.

Second, if you set the default value of txtTime to 0, then it will start at 0 every time you open the form.

Finally, in order to help you insert the record into the table I will have to know how the table relates to the form.
Is your form bound to this table? If so, then just set the control source for the txtTime text box to the [elapsed time] field in your table.
If not, then you will have to go find the record in code.

How does the record relate to the data displayed on the form? Is the person's name on the form, and so you would like to go add an [elapsed time] record to that person's name when he/she closes the form?
 
Timer event

I made the txtTimer (hidden) textbox have the control property set to the timeinterval field in the table that contains all the data for this form ( the form is bound to the table). This DB is set up where each form = a table (note, I did not design this monster). For instance, the preop form feeds info into the preop table ONLY. Each person entered = 1 record. (this DB is NOT relational). SO, at the end of each row (person) I have an elapsed time field, which I want to get filled in automatically each time she finishes entering and exits the form.
When I try on a sample form, instead of elapsed time I just see 00:00. There is only one data entry person, so that will not be a problem.
 
So, was there a question in that last post? Did you get the timer to work? Were you able to post the data where you wanted?

You said you are not seeing the elpased time incrementing?? Did you put the code in correctly? Did you set the timer to 1000 (1 second)? Did you activate the On Timer Event?

Why not just bind the txtTime Field directly to the table field [Elapsed Time] that sits behind your form? This way it is automatically posting to whatever record is current on the form.
 
Timer problem

Followed all your instructions and rechecked everything. txtTime default value = 0 (on hidden text box). Timer interval 1000 on form. On timer event in form set with Me.txtTime=Me.txtTime + 1. txtTime's control is Time in the table bound to the form. Is there some code I need to put on the onOpen event of the form or something to start the timer, and should it stop automatically when I exit the form? Sorry this is so much of a problem, but it is critical I get this to work. Thanks.
 
Here is a sample (very raw)...

Notice that Form's On Current Event Sets Me.SecondsElapsed = 0

This means that if you change records, then the new Person's time starts over and the former person's Elapsed time remains intact.

Good Luck..
 

Attachments

Timer fixed

Thanks so much for the help. I had the field in the table that was bound to the form set to TIME instead of number, as soon as I changed that, it worked fine. The attachment let me check all the properties and make sure I had them all set right. Thanks again!
 

Users who are viewing this thread

Back
Top Bottom