Using a timer (with Start, Pause, and Stop) to count length of going thru the form

Hi Cameron

I have a start button to start the timer.
the users cannot forget to start the timer cause it's part of their job to use the buttons (start, pause/continue)
 
Hi Cameron

I set the time interval to 0 in the property box and it's working the way i wanted.
now when i press the save button to store the records into the database, i got an error message - "the value you entered isn't valid for this field."
 
just for your info, i didnt not set "yes" to the required fields. in fact, when i do testing, i filled in all the fields!
 
I had a look at the database you uploaded the other day and put a breakpoint in the code behind your Save button so I could see what was happening. The error is being triggered because you are trying to save a value like 0:10 in a number field.

As an aside, I could not compile your database at first as it seemed to refer to a field on the form called Me.Duration that did not exist. I changed it to Me.CallDuration, which is the field you are displaying on the form and could then compile the database and receive the error you mentioned.

I looking at your timer event code, you can easily add the minutes and seconds together and store the total seconds in the database.
Code:
Private Sub Save_Click()
On Error GoTo Err_Save_Click
    Me.CallScore = Me.Call_Score
    Me.CallLength = Me.txtActualMinutes * 60 + Me.txtActualSeconds
    DoCmd.GoToRecord , , acNewRec
Exit_Save_Click:
    Exit Sub
Err_Save_Click:
    MsgBox Err.Description
    Resume Exit_Save_Click
 
End Sub

It is also a good practice to prefix your controls with the type of control (Textbox = txt, Combo = cbo). This will also make it easy to see when you are refering to the control or to the actual underlying foeld name.
 
yeh, i will remember to the prefix with the type of control in the future!

can i store the total value in min:sec instead of sec only?
cause i did some testing after making the changes and it looks weird!
 
what if i just create a real time boxes - "start time" and "end time" boxes!
and then substract the two which gives me the duration of call time!
would that be easier?
 
start & end time would work if you don't need to pause. To be honest though, working in seconds is easier as it can be a pain to work with time values especially if you want to group and sum them for any reports.

You can easily sum seconds and then display them in a query. The sample below displays the total time formated mm:ss and then seperated out in a column for minutes and then seconds.

Code:
SELECT Format([CallLength]\60,"00") & ":" & Format([CallLength] Mod 60,"00") AS TotalTime, [callLength]\60 AS Minutes, [CallLength] Mod 60 AS [Second]
FROM [Call Integrity];
 
Hi CameronM

i will stick with your advice and not to change the time into min:sec. i dont want to complicate the whole thing.

regarding the code that you have posted, do i put it in the query section?


i am not familiar with the program and need a bit more instruction to guide me through! sorry, to be a pain!
 
The SELECT statement in my previous post is really just a sample query you could use and modify to get any reports etc that you may need when you want to work with minutes and seconds rather than just seconds.

You don't need to use it in the form at all, but try and use it as a new query, just to see how it works.
 

Users who are viewing this thread

Back
Top Bottom