Stopwatch

sstreet

Access Demon
Local time
Today, 03:42
Joined
Dec 5, 2002
Messages
50
I have used the Microsoft Create a Stopwatch Form in Access 2002 article:
Link to Article

I have used the stopwatch as part of a timesheet system to bill time spent on user Support projects. The Text Box is bound to a field, so that when the clock is stopped, the value is entered into the field.

The problem I have is that when I re-open the timer to add more time, it shows the time spent so far, but then starts recording from 00:00:00:00. How can I make it carry on from the previously recorded time?

Thanks in advance!
 
I have not read the link but if the timer starts a 0 again, try this

Use an hidden unbound control to hold the timer field, a hidden bound control to hold the stored value then a calculated field to show the stored value added to the timer control.

On the on_click of the stop button / close of the form, replace the bound control's value with that of the calculated field, updating the time in the table.

(Apols if this does not fit in with the stopwatch example - I'll try to have a look)
 
Thanks for your help.

The only problem I now have is trying to replace the bound control's value. I get the error "you can't assign a value to this object". How can I get around this?
 
How are you tring to copy the info from one to the other?
 
Me.txtBound = Me.txtCalculated

I suppose I could write a query to update the underlying table, but there must be an easier way?
 
Sorry, I've just read the link and the reason you are getting this error is because we are trying to add 2 text values!

The stopwatch form calculates the number of milliseconds then conveniently formats it into a HH:mm:ss:millisec format.

If you still wish to use this, you will need to store the millisecond value in the table. and show it on a hidden form on the form.

You can then use the method I described earlier BUT you will need to use a different add method. You will need to add the value in the hidden control to the elapsed time ie

Me.txtBound = Me.txtBound + TotalElapsedMilliSec

You could then modify the code in the Form_Timer to format the value into an easier to read format.

I personally would use a combination of textboxes and datediff to have the same (but not as accurate) effect.
 
The Calculated control works perfectly using CDate. The problem is replacing the value from the text box that is bound to the underlying table.

The error occurs when you try to manipulate that bound control's value with code.
 
Is it Enabled = Yes and Locked = No?
 
Yes. I think the only way to write to a bound control is through a query.
 
You should store each instance of time spent as an individual record via a subform, if Access or a user screws up you'll have no way of knowing that the total time shown is accurate
 
I have sorted it now, thanks for your help guys.

A value cannot be assigned to a bound control from the form's close event. I created a Complete time button and assigned the values from it's click event.
 

Users who are viewing this thread

Back
Top Bottom