Count up every second

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I am looking for a way to have a counter on my form:
1) Once the user opens the form and presses btnDIAL the counter for the
first time the counter starts counting up from 0.
2) even if btnDIAL is pressed again, the counter is no longer affected until
the form is close/re-opened and the btnDIAL is pressed again for the first
time when the form is opened.
3) There needs to be a pause toggle button to pause the counter.
4) The counter should increment every 60 seconds.

Thanks
 
Rod said:
I am looking for a way to have a counter on my form:
1) Once the user opens the form and presses btnDIAL the counter for the
first time the counter starts counting up from 0.
2) even if btnDIAL is pressed again, the counter is no longer affected until
the form is close/re-opened and the btnDIAL is pressed again for the first
time when the form is opened.
3) There needs to be a pause toggle button to pause the counter.
4) The counter should increment every 60 seconds.


Use the form's Timer event to count the minutes:
Me.txtCounter = Me.txtCounter + 1

Set the form's TimerInterval property to 60000 to start the
timer and set it to 0 to pause/stop the timer.
 
I'm already using that for a timer to display how long on the phone:

Private blnKeepingTime As Boolean 'Determines if a call is in place
Private dtmCallTime As Date 'Used by the timer to display call time

Private Sub Form_Current()
' Form or next record event
Me.btnDialNumber.Caption = "DIAL"
blnKeepingTime = False
dtmCallTime = TimeSerial(0, 0, 0)
Me.txtCallDuration.BackColor = RGB(255, 255, 255)
Me.txtCallDuration = Format(dtmCallTime, "nn:ss")
If Me.RESUME = 0 Then
grpScripts = 8
Else
grpScripts = 1
End If

'Set the message box
If Me.RESUME <> "0" Then
Me.txtMessage = "Resume"
Else
Me.txtMessage = "Referral"
End If

If txtMessage = "Resume" Then
Me.grpScripts = 1
Else
Me.grpScripts = 8
End If
Me.txtScript = DLookup("[Msg]", "tblScripts", "[ID] = " & Me.grpScripts)
End Sub

Private Sub Form_Load()
Me.TimerInterval = 1000

'Set the message box
If Me.RESUME <> "0" Then
Me.txtMessage = "Resume"
Else
Me.txtMessage = "Referral"
End If
End Sub

Private Sub Form_Timer()
If blnKeepingTime Then
dtmCallTime = DateAdd("s", 1, dtmCallTime)
Me.txtCallDuration = Format(dtmCallTime, "nn:ss")
If Minute(dtmCallTime) = 1 Then 'Flash background yellow
If Me.txtCallDuration.BackColor = RGB(255, 255, 255) Then
Me.txtCallDuration.BackColor = RGB(255, 255, 0)
Else
Me.txtCallDuration.BackColor = RGB(255, 255, 255)
End If
End If

If Minute(dtmCallTime) >= 3 Then 'Flash background red
If Me.txtCallDuration.BackColor = RGB(255, 255, 255) Then
Me.txtCallDuration.BackColor = RGB(255, 0, 0)
Else
Me.txtCallDuration.BackColor = RGB(255, 255, 255)
End If
End If
End If
End Sub

I need the timer to temm the user how long on the call, but I also need to
tell them how many minutes they have been in the form, thus my original
request. Any ideas?
 
You'll need another text box to display the time in the
form. Since you never set the TimerInterval to 0, you can
update the text box every timer event. Use your
blnKeepingTime flag variable to determine if the call time
should be updated or not ( presume the call button set the
flag to True)..

If that fairly obvious answer is not what you're looking
for, try explaining the problem in in more detail.
--
Marsh
MVP [MS Access]

I'm already using that for a timer to display how long on the phone:

Private blnKeepingTime As Boolean 'Determines if a call is in place
Private dtmCallTime As Date 'Used by the timer to display call time

Private Sub Form_Current()
' Form or next record event
Me.btnDialNumber.Caption = "DIAL"
blnKeepingTime = False
dtmCallTime = TimeSerial(0, 0, 0)
Me.txtCallDuration.BackColor = RGB(255, 255, 255)
Me.txtCallDuration = Format(dtmCallTime, "nn:ss")
If Me.RESUME = 0 Then
grpScripts = 8
Else
grpScripts = 1
End If

'Set the message box
If Me.RESUME <> "0" Then
Me.txtMessage = "Resume"
Else
Me.txtMessage = "Referral"
End If

If txtMessage = "Resume" Then
Me.grpScripts = 1
Else
Me.grpScripts = 8
End If
Me.txtScript = DLookup("[Msg]", "tblScripts", "[ID] = " & Me.grpScripts)
End Sub

Private Sub Form_Load()
Me.TimerInterval = 1000

'Set the message box
If Me.RESUME <> "0" Then
Me.txtMessage = "Resume"
Else
Me.txtMessage = "Referral"
End If
End Sub

Private Sub Form_Timer()
If blnKeepingTime Then
dtmCallTime = DateAdd("s", 1, dtmCallTime)
Me.txtCallDuration = Format(dtmCallTime, "nn:ss")
If Minute(dtmCallTime) = 1 Then 'Flash background yellow
If Me.txtCallDuration.BackColor = RGB(255, 255, 255) Then
Me.txtCallDuration.BackColor = RGB(255, 255, 0)
Else
Me.txtCallDuration.BackColor = RGB(255, 255, 255)
End If
End If

If Minute(dtmCallTime) >= 3 Then 'Flash background red
If Me.txtCallDuration.BackColor = RGB(255, 255, 255) Then
Me.txtCallDuration.BackColor = RGB(255, 0, 0)
Else
Me.txtCallDuration.BackColor = RGB(255, 255, 255)
End If
End If
End If
End Sub

I need the timer to temm the user how long on the call, but I also need to
tell them how many minutes they have been in the form, thus my original
request. Any ideas?

Marshall Barton said:
Use the form's Timer event to count the minutes:
Me.txtCounter = Me.txtCounter + 1

Set the form's TimerInterval property to 60000 to start the
timer and set it to 0 to pause/stop the timer.
 

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

Back
Top