Count Down

ddrew

seasoned user
Local time
Today, 21:52
Joined
Jan 26, 2003
Messages
911
I need to put in a countdown clock on to a form starting at 3 minutes and counting down to 0. I need to be able to start iand stop it on the click of a button. But I also need to be able to pause the clock and then continue. Ive looked around but am unable to find what i'm after, any offers or pointers.:confused:
 
Use three controls, two buttons and an unbound text box. Set the format of the text box to Short Time. Set the TimerInterval of the form to 1000(1 second). Add the following events to the form module:

Code:
Private Sub btnReset_Click()
Me.txtTimer = #3:00:00 AM#
End Sub

Private Sub btnStartStop_Click()
If Me.TimerInterval = 0 Then
Me.TimerInterval = 1000
Else
Me.TimerInterval = 0
End If
End Sub

Private Sub Form_Timer()
Me.txtTimer = DateAdd("n", -1, Me.txtTimer)
End Sub
 
Thanks

Many Thanks Fornatian,
this works a treat, I wonder if you could help just to enhance it a little.

As I have a real time clock on the form as well, everytime I press the 'Stop/Start' btn it stops the real time clock as well, how might I overcome this, also the user may not be always looking at the clock so I need an audiable 'beep'. I think this from the DoCmd but how do I get it to beep at 0.

Cheers!
 
Create the count down as a separate popup form?

IMO
 
Thanks

Yup, that did the trick, now how canI get a sound to play when theclock gets to 0
 
ddrew ,
I don't know if you managed to play the .wav you wanted to when the timer hit '0' so I thought I'd post this. Just change the 'modPlayWav' module call line to the .wav you want to play.

IMO
 

Attachments

Thanks

This is exactly what i required, I re-jigged the timer up to 180 (3 Mins) and that was that,;) :p :)
 
Just Supposing

Just Supposing I took your file and wanted to add a sound at, lets say, 30 secs from 0, how do I do that. I tried one thing but when it got to 30 it just did a rapid countdown, (30 secs in under 10), so clearly it wasnt right. Likewise I may need to put different sounds in at 1 min 30, 1min, 30 secs and then 0.
If I can do one then I thinki'll be able to do the rest.
 
ddrew,

Just add new call functions to the module, ie:

Option Compare Database
Option Explicit
Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal filename As String, ByVal snd_async As Long) As Long

Public Function PlayWaveFile(sWavFile As String)
If apisndPlaySound(sWavFile, 1) = 0 Then
End If
End Function

Public Function PlayWaveFileat5secs(sWavFile As String)
If apisndPlaySound(sWavFile, 1) = 0 Then
End If

End Function
Public Sub PlayWaveFile_Cord()
Call PlayWaveFile("C:\Windows\Media\Tada.wav")
End Sub

Public Sub PlayWaveFileat5secs_Cord()
Call PlayWaveFileat5secs("C:\Windows\Media\Tada.wav")
End Sub

and then call it from the ontimer event of the form:

Private Sub Form_Timer()

Me.Box1.BackColor = tc - 2550
Me.Text0.BackColor = tc - 2550
Me.Repaint
Me.Text0 = Me.Text0 - 1


If Me.Text0 = 5 Then 'HERE
Call PlayWaveFileat5secs_Cord
End If


If Me.Text0 = 0 Or Me.Text0 < 0 Then
Me.TimerInterval = 0

Call PlayWaveFile_Cord

MsgBox " TIME'S UP!!!"
DoCmd.Close acForm, "frmCountDown"
End If
tc = tc - 2550

End Sub


Hope this is what you needed.

IMO
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom