Need to create a constantly updated time field and period.

TrunksSenkawa

Registered User.
Local time
, 20:09
Joined
Oct 10, 2002
Messages
13
My problem is that I am creating a call log. I have a time field on the form set to automatically display the current time and store it in a field. Only problem is, the Time() function only recieves the current time when a new record is created. So if a new record is created and it sits there from 2:35 to 2:50, the time will still show 2:35. I need a way to get the time to continuously update every second. Also, I have a field called Period. I want the value of this field to be based on what is in the CurrentTime field. Eg if it is 8:30 to 10, period displays 1, 10:01 to 11:20 period displays 2. I have another question but I want to get this resolved first. Thanks!
 
Just a thought

THis is just an idea and I hope that someone will come up with something better but ,,,

If you use something like

Private Sub Form_Timer()
Me.text1.Requery
End Sub

and set the timer interval to something relevent that will update the field.
But does it need to be constantly updated or can you just store the current time on update of other fields.

Hope this gives you a start though.
Steve
 
How do you enter the code?

This isn't working. I set the form timer to 1000 and the timer event to the above code. Then, I created a text box with the default value as Time() and the control source as txtTime (which is where I want the time stored). I went to the form view and the text box displayed #name? How do I make it so that the text box stores the time and references the code?
 
I've done this using the method described by indecisiv and it worked OK.

I had a date/time field on the form called CallTime and it's ControlSource was =Time(), it's Format was set to LongTime.

Using the ONTimer (set to 1000 - 1sec intervals) I triggered the event which was -

Me!CallTime.Requery

You can see it ticking away the seconds on the form.

Because it is an unbound field you have to save it using code at the point of recording/printing the call.

HTH

Dave E
 
Ok thanks! But...

How do I store info in a field using code? Where would I place the assignment in the code?
 
Ditch the timer event. You don't need to keep updating the time display. In the BeforeUpdate event of the form, just store the current date/time. That way every time the record is saved, the date/time field is updated.

Me.LastUpdateDt = Now()
 
Didn't work

I put the code in the BeforeUpdate of both the time and date fields and started a new record at 2:35. I waited until 2:37 and entered the record. The table displayed 2:35 for that record.
 
Pat's sort of right....
I used the OnTimer property so that the call screen had the date and time continuously displayed, but when I saved the record all the fields on the form were unbound so were saved using code. The calldate and calltime were saved at that moment.

It would just mean opening a recordset based on the table and adding a new record.

I don't understand how you got such a big time difference when the saved time should have very precise.

HTH

Dave E
 
You put the code in the wrong event. I said to put it in the -
BeforeUpdate event of the form
 

Users who are viewing this thread

Back
Top Bottom