Ontimer Questions

  • Thread starter Thread starter The Boondock Saint
  • Start date Start date
T

The Boondock Saint

Im trying to use Ontimer,

What id like to do is have it start at 00:00 Mins and secs

I have a button to start the timer (makes time interval 100) and another
button to stop the timer (makes time interval 0)

Im using office 2000.......

Ive got the following code working but its showing the current time... I
really want it to start from 00:00 which is mins

also.... it will go upto 80mins aka 80:00.... can it still display that ....
and not a 1:20:00

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

Private Sub cmdClockStart_Click()
Me.TimerInterval = 1000
End Sub

Private Sub cmdClockEnd_Click()
Me.TimerInterval = 0
End Sub
 
Saint,

At the top of the form module, under where it says Option Compare
Database and Option Explicit, put likr this...
Dim SecondCount As Long

Then...

Private Sub Form_Timer()
SecondCount = SecondCount + 1
Me!lblClock.Caption = Format(SecondCount \ 60, "00") & ":" &
Format(SecondCount MOD 60, "00")
DoCmd.RepaintObject
End Sub

Private Sub cmdClockStart_Click()
Me.TimerInterval = 1000
End Sub

Private Sub cmdClockEnd_Click()
Me.TimerInterval = 0
SecondCount = 0
End Sub
 
Thanks for that Steve....
The following part is showing up as red text , does that mean there is a
error with it?

Me!lblClock.Caption = Format(SecondCount \ 60, "00") & ":" &
Format(SecondCount MOD 60, "00")

Cheers
Theboondocksaint
 
opps... I just needed to have it all on one line .. its working now....

When i use the stop button.. it tops the time... but then when i press the
start one.. it starts back at 00:01...
Is there anyway you can make it carry on from where it is stopped...

Cheers
 
Theboondocksaint,

Yes, just leave out the SecondCount = 0 line in the cmdClockEnd_Click()
procedure. But then, maybe you will need another button to reset to 0
if required?
 
I found a way.... just taking away the code for the stop button.. it was
making it go back to 0
 
Thanks Steve,
On the form, I have a text field called time.
Is there a way I can get the time which is ticking over into that text
field...
 
When the form loads it autostarts the time... is there a way that it can be
set not to start till the start button is pressed?

Cheers
Saint
 
Saint,

I would imagine this indicates that the Timer Interval is set to 1000 or
whatever by design. Set the Timer Interval property of the form to 0.
 
Saint,

Just to clarify terminology, forms don't have fields. Tables and
queries have fields. Forms have controls (textboxes, labels,
comboboxes, etc).

The word 'time' is a Reserved Word (i.e. has a special meaning) in
Access, and as such should not ne used as the name of a field or
control. Call the textbox Clock instead?

And to get to your question :-), yes just replace the line...
Me!lblClock.Caption = Format(SecondCount \ 60, "00") & ":" &
Format(SecondCount MOD 60, "00")
with...
Me.Clock = Format(SecondCount \ 60, "00") & ":" & Format(SecondCount
MOD 60, "00")

Not 100% sure without trying it - it may be appropriate to alse replace...
DoCmd.RepaintObject
with...
Me.Recalc
 
You were exactly right, as long as i set the value to 0 to start with.. it
doesnt start till the button is pressed.... Awesome Stuff

Thanks Steve.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Time VB 2
Timer gettin complicated! 4
Use Stopwatch to trigger event 2
hh:mm:ss on a timer 2
Forms Error Timer 3
The clock on forms 5
Clock or operator error? 2
VBA HELP PLEASE!!!! 2

Back
Top