John,
I just thought I would update you on this. The good news is that all the code is loaded in the form, the buttons made, and the text box set up. However, when I start the clock it runs for one second.
I have had a busy weekend so I have not been able to go through the code line by line.
I am thinking I need to put a loop in there.
I am at a conference for a few days so maybe I will get a chance to look at it there.
Thanks,
Bill
MN
--- In MS_Access_Professionals@yahoogroups.com, "Bill Singer" <Bill.Singer@...> wrote:
>
> John,
>
> Thanks and WOW!. I will try to work through this code this weekend. I will
> let you know how it goes.
>
>
>
> Bill Singer
>
>
>
> From: MS_Access_Professionals@yahoogroups.com
> [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of John Viescas
> Sent: Friday, November 30, 2012 11:20 AM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: Re: [MS_AccessPros] Timer
>
>
>
>
>
> Bill-
>
> OK. Let's assume the text box is called txtClock. Format="hh:mm:nn"
>
> Three command buttons: cmdStart (Caption START), cmdPause (Caption PAUSE,
> Enabled = No), cmdStop (Caption STOP, enabled = No)
>
> Private Sub cmdStart_Click()
> Dim datTimeValue As Date
> ' Make sure it's a valid date/time value
> If Not IsDate(Me.txtClock) Then
> MsgBox "You must enter a valid time value."
> Exit Sub
> End If
> ' Grab the value as a Time - strip off any date part
> datTimeValue = TimeValue(Me.txtClock)
> ' Put it back as hh:mm:ss
> Me.txtClock = datTimeValue
> ' Make sure it's not zero
> If Format(datTimeValue, "hh:mm:nn") = "00:00:00" Then
> MsgBox "You must set the starting time to something other than
> zero."
> Exit Sub
> End If
> ' Turn on the timer interval
> Me.TimerInterval = 1000
> ' Enable the other two buttons
> Me.cmdPause.Enabled = True
> Me.cmdStop.Enabled = True
> End Sub
>
> Private Sub Form_Timer()
> Dim datTimeValue As Date
> ' Grab the current value
> datTimeValue = TimeValue(Me.txtClock)
> ' Subtract 1 second
> datTimeValue = datTimeValue - #00:00:01#
> ' Update the visual
> Me.txtClock = datTimeValue
> ' If decremented to 0,
> If Format(datTimeValue, "hh:mm:nn") = "00:00:00" Then
> ' Turn off the timer
> Me.TimerInterval = 0
> ' Make a sound
> Beep
> ' Put the focus on the text box
> Me.txtClock.SetFocus
> ' Disable the Pause and Stop buttons
> Me.cmdPause.Enabled = False
> Me.cmdStop.Enabled = False
> End If
> End Sub
>
> Private Sub cmdPause_Click()
> ' Stop the timer
> Me.TimerInterval = 0
> End Sub
>
> Private Sub cmdStop_Click()
> ' Stop the timer
> Me.TimerInterval = 0
> ' Clear the text box
> Me.txtClock = #00:00:00#
> ' Put the focus there
> Me.txtClock.SetFocus
> ' Disable pause and stop
> Me.cmdPause.Enabled = False
> Me.cmdStop.Enabled = False
> End Sub
>
> That should get you started©
>
> John Viescas, Author
> Microsoft Access 2010 Inside Out
> Microsoft Access 2007 Inside Out
> Microsoft Access 2003 Inside Out
> Building Microsoft Access Applications
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
> -----Original Message-----
> From: Bill Singer <Bill.Singer@...
> <mailto:Bill.Singer%40at-group.net> >
> Reply-To: <MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com> >
> Date: Friday, November 30, 2012 5:33 PM
> To: <MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com> >
> Subject: RE: [MS_AccessPros] Timer
>
> John,
>
> Well I guess that is bad news and good news. I was hoping for some type of
> "Clock" function. The good news is that it can still be done. Your
> question at the end of your email made me laugh. Absolutely I will need
> help writing that code! Anything you can send my way would be great.
>
> Thanks,
>
> Bill Singer
>
> From: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> [mailto:MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com> ] On Behalf Of John
> Viescas
> Sent: Friday, November 30, 2012 9:59 AM
> To: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> Subject: Re: [MS_AccessPros] Timer
>
> Bill-
>
> If you just want a digital countdown, you can build your own with a Text
> Box and the Timer event. Enter the total time you want to start at in the
> text box, then click a Start button. Code behind the Start button would
> then set the form's TimerInterval property to 1000 (1000 milliseconds = 1
> second) to start the clock. In your On Timer event procedure, subtract 1
> second from the clock value. You could also provide a Pause button (set
> TimerInterval to 0 to stop it from firing) and a Stop button (set
> TimerInterval to 0 and set the Text Box to 0). Need some help writing the
> code?
>
> The other alternative is to search for a clock or countdown ActiveX
> control on the web.
>
> John Viescas, Author
> Microsoft Access 2010 Inside Out
> Microsoft Access 2007 Inside Out
> Microsoft Access 2003 Inside Out
> Building Microsoft Access Applications
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
> -----Original Message-----
> From: Bill Singer <Bill.Singer@...
> <mailto:Bill.Singer%40at-group.net>
> <mailto:Bill.Singer%40at-group.net> >
> Reply-To: <MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> <mailto:MS_Access_Professionals%40yahoogroups.com> >
> Date: Friday, November 30, 2012 4:32 PM
> To: <MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> <mailto:MS_Access_Professionals%40yahoogroups.com> >
> Subject: [MS_AccessPros] Timer
>
> I am wondering if access has a clock function or something that would work
> like a game clock in a football game. I want to set the time, click the
> start button and then have the clock start counting down.
>
> Thanks,
>
> Bill
>
> MN
>
> [Non-text portions of this message have been removed]
>
> ------------------------------------
>
> Yahoo! Groups Links
>
> [Non-text portions of this message have been removed]
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (6) |
Tidak ada komentar:
Posting Komentar