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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a clock in access

Status
Not open for further replies.

paulbradley

Programmer
Oct 9, 2002
158
GB
I've made a form which has a timer interval of 1000. Every second 1 is added onto the seconds until it equaly 60 when it resets to zero and one added to the minutes button.

I've made a reset button that makes every value 0 again but I'm stuck on how to do a stop, go or pause button. I've tried having a variable (say stopvalue) and making this True or "y" when stop is pressed and then having an if function on the timer so that it only does it if stopvalue if False or "n". It seems every second it resets my value to null thus making it useless. Anyone offer any suggestions?

Many Thanks.
 
Can you paste a copy of the code so we can try to debug it?

BAKEMAN [pimp]
 
If you wish to pause or stop the timer then set the timer interval value to zero
 
Is there some code to change the timer interval?

Anyway - here's the code for you to debug:


Private Sub Form_Open(Cancel As Integer)

[min] = 0
[sec1] = 0
[sec2] = 0
stopvalue = "Y"

End Sub

Private Sub Form_Timer()

If stopvalue = "n" Then

If [sec2] < 10 Then
[sec2] = [sec2] + 1
End If

If [sec2] = 10 Then
[sec2] = 0
[sec1] = [sec1] + 1
End If

If ([sec1] = 6) Then
[min] = [min] + 1
[sec1] = 0
[sec2] = 0
End If

End If

End Sub

Private Sub go_Click()

stopvalue = &quot;n&quot;

End Sub

Private Sub Reset_Click()

[min] = 0
[sec1] = 0
[sec2] = 0

End Sub

Private Sub stop_Click()

stopvalue = &quot;y&quot;

End Sub
 
Private Sub Form_Open(Cancel As Integer)
[min] = 0
[sec1] = 0
[sec2] = 0
' stopvalue = &quot;Y&quot;
End Sub
Private Sub Form_Timer()
' If stopvalue = &quot;n&quot; Then
Me.Timerinterval = 1000
If [sec2] < 10 Then
[sec2] = [sec2] + 1
Elseif [sec2] = 10 Then
[sec2] = 0
[sec1] = [sec1] + 1
Elseif [sec1] = 6 Then
[min] = [min] + 1
[sec1] = 0
[sec2] = 0
End If
End Sub
Private Sub go_Click()
Me.TimerInterval = 1000
' stopvalue = &quot;n&quot;
End Sub
Private Sub Reset_Click()
Me.TimerInterval = 0
[min] = 0
[sec1] = 0
[sec2] = 0
End Sub
Private Sub stop_Click()
Me.TimerInterval = 0
' stopvalue = &quot;y&quot;
End Sub
 
Sounds like you're looking for a stopwatch function rather than a clock, right? A clock is simply a text box with these properties:

ControlSource: =Now()
Format: hh:nn:ss

Date would be a text box:

ControlSource: =Date()
Format: Long Date Newposter
&quot;Good judgment comes from experience. Experience comes from bad judgment.&quot;
 
while the tedium of calculating the various 'rollovers' can, of course, be accomplished, WHY would anyone want to do so? just set a text box (or label) to the formatted difference between a start time and the current time. It should take only a few lines of code to accomplish the entire process!

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Hi Paul
Just a thought - it is much simpler to use one textbox for seconds instead of two, the code would shrink as follows:
If [sec2] < 10 Then
[sec2] = [sec2] + 1
Elseif [sec2] = 10 Then
[sec2] = 0
[sec1] = [sec1] + 1
Elseif [sec1] = 6 Then
[min] = [min] + 1
[sec1] = 0
[sec2] = 0
Would become
If [second] < 59 Then
[second] = [second] + 1
Else
[second] = 00
[minute] = [minute] + 1
End if
What do you think??
 
How do you make the clock time acutall move make a working clock !!! Auto Update ?
8:14.21....8:14.22...ect
 
I've moved into making this in VB6 and have added an options menu where u can choose to countdown and select where from. I've got this sorted and when you exit the options form the value to countdown from is read in by the clock. However I have tried making a variable (called countdown) which is defined as 1 to coundown or 0 to not. On open this variable is 0 and what I want is that if they select the countdown radio button this value to go to one and the timer to countdown. The code to countdown is sorted but the variable dosen't seem to make any difference as the counter will only do what it is told to do 'On Open'. This is the code used on the option menu:

Dim countdown As Single
Private Sub countdownb_Click()

min.Locked = False
min.Enabled = True

sec1.Locked = False
sec1.Enabled = True

sec2.Locked = False
sec2.Enabled = True

up.Enabled = True
down.Enabled = True

End Sub

Private Sub countup_Click()

min.Locked = True
min.Enabled = False

sec1.Locked = True
sec1.Enabled = False

sec2.Locked = True
sec2.Enabled = False

up.Enabled = False
down.Enabled = False

End Sub

Private Sub down_Click()

If [sec2] < 10 Then
[sec2] = [sec2] - 1
End If

If [sec2] < 0 Then
[sec2] = 9
[sec1] = [sec1] - 1
End If

If ([sec1] < 0) Or ([sec2] < 0) Then
[min] = [min] - 1
[sec1] = 5
[sec2] = 9
End If

If ([sec2] = 0) And ([sec1] = 0) And ([min] = 0) Then
down.Enabled = False
End If

up.Enabled = True

End Sub

Private Sub Form_Load()
[min] = 0
[sec1] = 0
[sec2] = 0
End Sub

Private Sub ok_Click()

If countdownb = True Then
countdown = 1
End If

Form2.Hide

Form1.min = min
Form1.sec1 = sec1
Form1.sec2 = sec2

End Sub

Private Sub up_Click()

If [sec2] < 10 Then
[sec2] = [sec2] + 1
End If

If [sec2] = 10 Then
[sec2] = 0
[sec1] = [sec1] + 1
End If

If [sec1] = 6 Then
[min] = [min] + 1
[sec1] = 0
[sec2] = 0
End If

down.Enabled = True

If ([min] = 99) And ([sec1] = 5) And ([sec2] = 9) Then
up.Enabled = False
End If

End Sub



Many thanks again in advance!
 
Sorry Paul there are lots of things in here that I can't understand how or when they are intended to work.
eg: If countdownb = True Then
What is countdownb??

Why not use the option group with the radio buttons only.
If opt3 = true then >> redio button for countdown
Me.TimerInterval = 1000
Me.sec1 = Right(CountdownVal,1) >>>CountDownVal is input
Me.sec2 = Mid(CountdownVal,1,1)
Me.Min = Left(CountDownVal,2)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top