Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time Function

Status
Not open for further replies.

Dina01

Programmer
Mar 26, 2002
204
0
0
CA
I have a continuos form and on this form I have a textbox named "txtHrsRecu" and another one named CallTime.

Most of my textbox are linked to my table named Data_tb except for the CallTime, since I want the Call time to calculate how long the call has been open, therefore take the information stored in table on field HrsRecu and keep it looping with the time now therefore time()

I also have a lable named lblClock, which shows the curret data and time.

Here is my code, but it's not working properly...
It calculate the time for every records, but they are all the same, it doesn't take in account the time that is stored in HrsRecu in my table....

Can someone please help..
***************************
Dim StartTime As Date

Private Sub Form_Timer()

Me![CallTime] = DateDiff("n", StartTime, Time())
Me!lblClock.Caption = Format(Now, "dddd, mmm d yyyy, hh:mm:ss AMPM")

End Sub

Private Sub Form_Open(Cancel As Integer)

StartTime = Me!HrsRecuCall
Me.TimerInterval = 1000

End Sub

Private Sub Btn_HrsFinCall_Click()

' Stop calculating Time
Me.TimerInterval = 0

End Sub


*******
Btn_HrsFinCall is a button that I press to close the call but I need it to also close the looping time and store it in the Data_tb.....


 
Private Sub Form_Timer()

Me![CallTime] = DateDiff("n", StartTime, Time())
Me!lblClock.Caption = Format(Now, "dddd, mmm d yyyy, hh:mm:ss AMPM")
Me.Repaint
End Sub

Aivars [pipe]
 
I added the Me.Repaint but it still does the same thing
 
Can anyone help me with this question
 
the calculation needs to be in the section of the form where the textboz (CallTime) is displayed. Placing the calc in the timer routime does not permit the procedure to distinguish beween the various instantiations of the control.

I do net see the need for the timer event, except to do the refresh / repaint of the form.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
I have to agree with MichaelRed.

I would think if you wanted this info, you have 2 viable options.

1) It's not a good practice to store calculated fields (CallTime for instance) so it would be better to store Call Start Time (input on Form_Open) and End Time (on the click of your button).

2) If you want to store the calc field anyway, try puting 2 invisible textboxxes on your form and bind one to the field for CallTime. (leave the other unbound) Let's call them txtCallTime (bound) and txtStartTime (unbound)
Then try something like this: (this is written on the fly so bear with me)

Private StartTime As Date
Private Sub Form_Timer()

Me!lblClock.Caption = Format(Now, "dddd, mmm d yyyy, hh:mm:ss AMPM")
Me.Repaint
End Sub

Private Sub Form_Open(Cancel As Integer)

StartTime = Now()
Me.TimerInterval = 1000

End Sub

Private Sub Btn_HrsFinCall_Click()

' Stop calculating Time
Me!txtCallTime = DateDiff("n", StartTime , Now())
Me.TimerInterval = 0

End Sub



Kyle [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top