Time and date problems

Holmes

Registered User.
Local time
Today, 22:23
Joined
Dec 15, 2006
Messages
42
Hello,

Hopefully someone can help. I have a table that is used to monitor calls, there is on field called StartOfCall and another called EndOfCall.

All I am trying to do is to put a button onto the form so that when you click on it it enters the current time into the start of the call field. Then when you click on another button it enters the time again for the end of the call.

the form has a text box to display the startofcall and endofcall. I have had a look at the onclick command and using the time() function but can not see how to get the time into the required fields.

The final part is to display the call duration(EndOfCall(or current time) - StartOfCall)

Is there anyway to display this on the form as the call is in progress?

Similarly there is a button to log the date of the call so I need to copy the current date into the DateOfCall field.


Many thanks.

B Holmes.
 
Firstly the in call counter:

Put a label field on your form and a timer control. On the Click event of "StartCall", set the timer interval to 1 second (1000 IIRC) and set it running. In the tick event of the timer use TimeLabel.Caption = TimeLabel.Caption +1. You can use format to show as minutes and seconds if that's what you require, or do a DateDiff based on Now() and the recorded start time.

To show the start time in the text box, in the on_click event of the button you need to use:

me.textboxname.text = Now()

You need to replace "textboxname" with the name you've given your text box.

On clicking the stop button stop the timer and update the end time in the same manner as setting the start above.
 
Ok thanks for that but I can't find the timer anywhere, where the heck is it!

cheers
 
Your start and stop fields need to have a "Short Time" format so that they show the time as hours and minutes (eg 15:30 for 3.30 pm). Create a text box that calculates the time between start and end times using =[starttime]-[endtime] as the control source of the text box.

HTH
 
Ok so I now have a button that will input the start time and stop time into the respective fields. However it does not write these values into the table,
I'v almost sorted it!

thanks for all the help btw, I'll probably be posting some more questions also, so please bear with me.

Cheers.
 
The control source of the start and finish text boxes must be the relevant fields of the forms record source or they won't store the data.
 
not to worry I've got it sorted by putting the control source as the required field. I'll just get the call duration sorted and date insert and job is a good un.

Many thanks.
 
I can't seem to get the call duration to work, using the start of call - end of call only works when I have closed the call , what I really need is some means of showing the call duration in real time, I'm just getting stuck with the timer click event!
 
Set the Form timer interval to, say, 1000 milliseconds. In the OnTimer event of the form, enter
txtCallDuration= Now() - txtStartTime
where txtCallDuration is the name of the text box which displays the duration, and txtStartTime is the text box displaying the start time of the call. Format txtCallDuration as nn:ss
 
Last edited:
Almost done, only prob is I can't figure out how to stop the timer. Obviously I want to do it when the stop call button is pressed but I don't know what the command is.

Once again many thanks for all this help.
 
I think the Timer works all the time, I would use different fields to display the final call duration and the running lapsed time, this latter field set as visible=False on form load, visible=true and value=0 in your startcommand code and visible=False in your stop command code, thus the running lapsed time only displays between start and stop.

Brian
 
Shows when I last used Access for UI development!!

Set the timerInterval = 1000 and have a form Level boolean "running" which you set to true as part of the click event for the button.

In

Private Sub Form_Timer()

if running = true
me.txtCallDuration.text = now()-txtStartTime.text
end if

End Sub

You may prefer to use DateDiff to work out the time.
 
Thanks for all the help, will test 1st thing on Monday.
 
fwiw

me.textboxname.text = Now()

should be:

me.textboxname.value = Now()

just to help any one who reads this thread.
 

Users who are viewing this thread

Back
Top Bottom