Timer updated on form

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

Guest

A2003
I have people who loose track of how long they are on a call.

1) They would like to have a timer on the form showing how long it has been
since the user pressed the DialButton - counting up the min:sec would be
fine.
2) If time is greater than 3 minutes they would like the color of min:sec to
change to red.

Thanks
 
Here is a basic concept.
In the Click event of DialButton set the value of the Call Timer text box to
00:00 and start a timer event that will update the Timer text box every
second. And in the Change event of the Call Timer text box, change the back
color when it's value is = "00:00"
 
I create:
tbxCallTimer = 0
Me.tbxCallTimer = Timer

How do I update this every second?
I tried the property format of nn:ss, but that did not give me 02:12 for 2
minutes 12 seconds as Ihad hoped.
 
Private dtmCallTime as Date ' Form Level variable

In the Click event of the DailButton:

dtmCallTime = timeserial(0,0,0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

In the Timer event of the form

Private Sub Form_Timer()
Dim dtmTimeCheck as Date

dtmTimeCheck = TimeSerial(0,3,0)
dtmCallTime = DateAdd("s",1,dtmCallTime)
Me.txtCall Duration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
Iif(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

You will also need to reset everything after a call is complete. Put this
right after you complete the call:

Me.txtCallDuration.BackColor = RGB(255,255,255)
Me.TimerInterval = 0
 
Your code is working well.
The call is complete when the person goes to the next record. How can I
place your "Call Complete" code so it appears when the user moves to the next
record, i.e. open next record or leave current record? They move to the next
record by using the next record arrow in the bottom left of the frame.
 
Glad to hear it is working. It was totally untested.
Put that code in the Current event of the form.
 
It resets the clock, but the clock starts without me pressing the dial button
when I advance the record. Here is a copy of what I have and where the key
components are in the editor:

Option Compare Database
Private dtmCallTime As Date ' Form Level variable
Private Sub Form_Timer()
Dim dtmTimeCheck As Date

dtmTimeCheck = TimeSerial(0, 3, 0)
dtmCallTime = DateAdd("s", 1, dtmCallTime)
Me.txtCallDuration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
IIf(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

Private Sub Form_Current()
'next record. This will reset the clock.
dtmCallTime = TimeSerial(0, 0, 0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

End Sub

Private Sub btnDialNumber_Click()
On Error GoTo Err_btnDialNumber_Click

Dim stDialStr As String
Dim PrevCtl As Control
Const ERR_OBJNOTEXIST = 2467
Const ERR_OBJNOTSET = 91
Const ERR_CANTMOVE = 2483

Set PrevCtl = Screen.PreviousControl

Me.Text131 = DLookup("[Msg]", "tblScripts", "[ID] = " & Me.Frame124)
CALLED_ON = Date
CALL_RESULTS = "Message"

Me.tbxMsgToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON] =
" & Format(Date, "\#mm\/dd\/yyyy\#") & " And [CALL_RESULTS] = 'Message'"), 0)
Me.tbxCallsToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON]
= " & Format(Date, "\#mm\/dd\/yyyy\#")), 0)

Select Case [RESUME]
Case -1
Frame124 = 1
Case 0
Frame124 = 8
End Select

Application.Run "utility.wlib_AutoDial", tbxDIALNUMBER

Exit_btnDialNumber_Click:
Exit Sub

Err_btnDialNumber_Click:
If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Or (Err =
ERR_CANTMOVE) Then
Resume Next
End If
MsgBox Err.Description
Resume Exit_btnDialNumber_Click

End Sub
 
In the current event, you are setting the timer interval to 1 second. You
need to set it to 0. Then you set it to 1000 in the Button Click event to
start it.

Rod said:
It resets the clock, but the clock starts without me pressing the dial button
when I advance the record. Here is a copy of what I have and where the key
components are in the editor:

Option Compare Database
Private dtmCallTime As Date ' Form Level variable
Private Sub Form_Timer()
Dim dtmTimeCheck As Date

dtmTimeCheck = TimeSerial(0, 3, 0)
dtmCallTime = DateAdd("s", 1, dtmCallTime)
Me.txtCallDuration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
IIf(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

Private Sub Form_Current()
'next record. This will reset the clock.
dtmCallTime = TimeSerial(0, 0, 0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

End Sub

Private Sub btnDialNumber_Click()
On Error GoTo Err_btnDialNumber_Click

Dim stDialStr As String
Dim PrevCtl As Control
Const ERR_OBJNOTEXIST = 2467
Const ERR_OBJNOTSET = 91
Const ERR_CANTMOVE = 2483

Set PrevCtl = Screen.PreviousControl

Me.Text131 = DLookup("[Msg]", "tblScripts", "[ID] = " & Me.Frame124)
CALLED_ON = Date
CALL_RESULTS = "Message"

Me.tbxMsgToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON] =
" & Format(Date, "\#mm\/dd\/yyyy\#") & " And [CALL_RESULTS] = 'Message'"), 0)
Me.tbxCallsToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON]
= " & Format(Date, "\#mm\/dd\/yyyy\#")), 0)

Select Case [RESUME]
Case -1
Frame124 = 1
Case 0
Frame124 = 8
End Select

Application.Run "utility.wlib_AutoDial", tbxDIALNUMBER

Exit_btnDialNumber_Click:
Exit Sub

Err_btnDialNumber_Click:
If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Or (Err =
ERR_CANTMOVE) Then
Resume Next
End If
MsgBox Err.Description
Resume Exit_btnDialNumber_Click

End Sub


Klatuu said:
Glad to hear it is working. It was totally untested.
Put that code in the Current event of the form.
 
Rod,
I forgot something important. Access Help says to set the timer interval in
the Load event of the form. Since it is not resetting and running correctly,
I will need to play with it and trick it. I know I can do it, I did it
several years ago, but I don't remember exactly how. I will play with it
over the weekend, and get back to you.

My apologies for wasting your time chasing this problem. Once I get all the
egg off my face, I will get it fixed and get back to you.

Rod said:
The clock is running from zero. It starts when I move to the next record
regardless if I press the dial button. It needs to only start when I press
the button. I have the code in the right location, but something is kicking
it off regardless. Pressing the dial button does not even reset the clock -
something os overriding the dial button statement to start the clock.

Klatuu said:
In the current event, you are setting the timer interval to 1 second. You
need to set it to 0. Then you set it to 1000 in the Button Click event to
start it.

Rod said:
It resets the clock, but the clock starts without me pressing the dial button
when I advance the record. Here is a copy of what I have and where the key
components are in the editor:

Option Compare Database
Private dtmCallTime As Date ' Form Level variable
Private Sub Form_Timer()
Dim dtmTimeCheck As Date

dtmTimeCheck = TimeSerial(0, 3, 0)
dtmCallTime = DateAdd("s", 1, dtmCallTime)
Me.txtCallDuration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
IIf(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

Private Sub Form_Current()
'next record. This will reset the clock.
dtmCallTime = TimeSerial(0, 0, 0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

End Sub

Private Sub btnDialNumber_Click()
On Error GoTo Err_btnDialNumber_Click

Dim stDialStr As String
Dim PrevCtl As Control
Const ERR_OBJNOTEXIST = 2467
Const ERR_OBJNOTSET = 91
Const ERR_CANTMOVE = 2483

Set PrevCtl = Screen.PreviousControl

Me.Text131 = DLookup("[Msg]", "tblScripts", "[ID] = " & Me.Frame124)
CALLED_ON = Date
CALL_RESULTS = "Message"

Me.tbxMsgToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON] =
" & Format(Date, "\#mm\/dd\/yyyy\#") & " And [CALL_RESULTS] = 'Message'"), 0)
Me.tbxCallsToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON]
= " & Format(Date, "\#mm\/dd\/yyyy\#")), 0)

Select Case [RESUME]
Case -1
Frame124 = 1
Case 0
Frame124 = 8
End Select

Application.Run "utility.wlib_AutoDial", tbxDIALNUMBER

Exit_btnDialNumber_Click:
Exit Sub

Err_btnDialNumber_Click:
If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Or (Err =
ERR_CANTMOVE) Then
Resume Next
End If
MsgBox Err.Description
Resume Exit_btnDialNumber_Click

End Sub


:

Glad to hear it is working. It was totally untested.
Put that code in the Current event of the form.

:

Your code is working well.
The call is complete when the person goes to the next record. How can I
place your "Call Complete" code so it appears when the user moves to the next
record, i.e. open next record or leave current record? They move to the next
record by using the next record arrow in the bottom left of the frame.

:

Private dtmCallTime as Date ' Form Level variable

In the Click event of the DailButton:

dtmCallTime = timeserial(0,0,0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

In the Timer event of the form

Private Sub Form_Timer()
Dim dtmTimeCheck as Date

dtmTimeCheck = TimeSerial(0,3,0)
dtmCallTime = DateAdd("s",1,dtmCallTime)
Me.txtCall Duration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
Iif(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

You will also need to reset everything after a call is complete. Put this
right after you complete the call:

Me.txtCallDuration.BackColor = RGB(255,255,255)
Me.TimerInterval = 0
:

I create:
tbxCallTimer = 0
Me.tbxCallTimer = Timer

How do I update this every second?
I tried the property format of nn:ss, but that did not give me 02:12 for 2
minutes 12 seconds as Ihad hoped.

:

Here is a basic concept.
In the Click event of DialButton set the value of the Call Timer text box to
00:00 and start a timer event that will update the Timer text box every
second. And in the Change event of the Call Timer text box, change the back
color when it's value is = "00:00"

:

A2003
I have people who loose track of how long they are on a call.

1) They would like to have a timer on the form showing how long it has been
since the user pressed the DialButton - counting up the min:sec would be
fine.
2) If time is greater than 3 minutes they would like the color of min:sec to
change to red.

Thanks
 
The clock is running from zero. It starts when I move to the next record
regardless if I press the dial button. It needs to only start when I press
the button. I have the code in the right location, but something is kicking
it off regardless. Pressing the dial button does not even reset the clock -
something os overriding the dial button statement to start the clock.

Klatuu said:
In the current event, you are setting the timer interval to 1 second. You
need to set it to 0. Then you set it to 1000 in the Button Click event to
start it.

Rod said:
It resets the clock, but the clock starts without me pressing the dial button
when I advance the record. Here is a copy of what I have and where the key
components are in the editor:

Option Compare Database
Private dtmCallTime As Date ' Form Level variable
Private Sub Form_Timer()
Dim dtmTimeCheck As Date

dtmTimeCheck = TimeSerial(0, 3, 0)
dtmCallTime = DateAdd("s", 1, dtmCallTime)
Me.txtCallDuration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
IIf(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

Private Sub Form_Current()
'next record. This will reset the clock.
dtmCallTime = TimeSerial(0, 0, 0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

End Sub

Private Sub btnDialNumber_Click()
On Error GoTo Err_btnDialNumber_Click

Dim stDialStr As String
Dim PrevCtl As Control
Const ERR_OBJNOTEXIST = 2467
Const ERR_OBJNOTSET = 91
Const ERR_CANTMOVE = 2483

Set PrevCtl = Screen.PreviousControl

Me.Text131 = DLookup("[Msg]", "tblScripts", "[ID] = " & Me.Frame124)
CALLED_ON = Date
CALL_RESULTS = "Message"

Me.tbxMsgToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON] =
" & Format(Date, "\#mm\/dd\/yyyy\#") & " And [CALL_RESULTS] = 'Message'"), 0)
Me.tbxCallsToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON]
= " & Format(Date, "\#mm\/dd\/yyyy\#")), 0)

Select Case [RESUME]
Case -1
Frame124 = 1
Case 0
Frame124 = 8
End Select

Application.Run "utility.wlib_AutoDial", tbxDIALNUMBER

Exit_btnDialNumber_Click:
Exit Sub

Err_btnDialNumber_Click:
If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Or (Err =
ERR_CANTMOVE) Then
Resume Next
End If
MsgBox Err.Description
Resume Exit_btnDialNumber_Click

End Sub


Klatuu said:
Glad to hear it is working. It was totally untested.
Put that code in the Current event of the form.

:

Your code is working well.
The call is complete when the person goes to the next record. How can I
place your "Call Complete" code so it appears when the user moves to the next
record, i.e. open next record or leave current record? They move to the next
record by using the next record arrow in the bottom left of the frame.

:

Private dtmCallTime as Date ' Form Level variable

In the Click event of the DailButton:

dtmCallTime = timeserial(0,0,0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

In the Timer event of the form

Private Sub Form_Timer()
Dim dtmTimeCheck as Date

dtmTimeCheck = TimeSerial(0,3,0)
dtmCallTime = DateAdd("s",1,dtmCallTime)
Me.txtCall Duration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
Iif(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

You will also need to reset everything after a call is complete. Put this
right after you complete the call:

Me.txtCallDuration.BackColor = RGB(255,255,255)
Me.TimerInterval = 0
:

I create:
tbxCallTimer = 0
Me.tbxCallTimer = Timer

How do I update this every second?
I tried the property format of nn:ss, but that did not give me 02:12 for 2
minutes 12 seconds as Ihad hoped.

:

Here is a basic concept.
In the Click event of DialButton set the value of the Call Timer text box to
00:00 and start a timer event that will update the Timer text box every
second. And in the Change event of the Call Timer text box, change the back
color when it's value is = "00:00"

:

A2003
I have people who loose track of how long they are on a call.

1) They would like to have a timer on the form showing how long it has been
since the user pressed the DialButton - counting up the min:sec would be
fine.
2) If time is greater than 3 minutes they would like the color of min:sec to
change to red.

Thanks
 
No problem. I have learned a lot working with you. Anxiously awaiting your
reply...

Klatuu said:
Rod,
I forgot something important. Access Help says to set the timer interval in
the Load event of the form. Since it is not resetting and running correctly,
I will need to play with it and trick it. I know I can do it, I did it
several years ago, but I don't remember exactly how. I will play with it
over the weekend, and get back to you.

My apologies for wasting your time chasing this problem. Once I get all the
egg off my face, I will get it fixed and get back to you.

Rod said:
The clock is running from zero. It starts when I move to the next record
regardless if I press the dial button. It needs to only start when I press
the button. I have the code in the right location, but something is kicking
it off regardless. Pressing the dial button does not even reset the clock -
something os overriding the dial button statement to start the clock.

Klatuu said:
In the current event, you are setting the timer interval to 1 second. You
need to set it to 0. Then you set it to 1000 in the Button Click event to
start it.

:

It resets the clock, but the clock starts without me pressing the dial button
when I advance the record. Here is a copy of what I have and where the key
components are in the editor:

Option Compare Database
Private dtmCallTime As Date ' Form Level variable
Private Sub Form_Timer()
Dim dtmTimeCheck As Date

dtmTimeCheck = TimeSerial(0, 3, 0)
dtmCallTime = DateAdd("s", 1, dtmCallTime)
Me.txtCallDuration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
IIf(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

Private Sub Form_Current()
'next record. This will reset the clock.
dtmCallTime = TimeSerial(0, 0, 0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

End Sub

Private Sub btnDialNumber_Click()
On Error GoTo Err_btnDialNumber_Click

Dim stDialStr As String
Dim PrevCtl As Control
Const ERR_OBJNOTEXIST = 2467
Const ERR_OBJNOTSET = 91
Const ERR_CANTMOVE = 2483

Set PrevCtl = Screen.PreviousControl

Me.Text131 = DLookup("[Msg]", "tblScripts", "[ID] = " & Me.Frame124)
CALLED_ON = Date
CALL_RESULTS = "Message"

Me.tbxMsgToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON] =
" & Format(Date, "\#mm\/dd\/yyyy\#") & " And [CALL_RESULTS] = 'Message'"), 0)
Me.tbxCallsToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON]
= " & Format(Date, "\#mm\/dd\/yyyy\#")), 0)

Select Case [RESUME]
Case -1
Frame124 = 1
Case 0
Frame124 = 8
End Select

Application.Run "utility.wlib_AutoDial", tbxDIALNUMBER

Exit_btnDialNumber_Click:
Exit Sub

Err_btnDialNumber_Click:
If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Or (Err =
ERR_CANTMOVE) Then
Resume Next
End If
MsgBox Err.Description
Resume Exit_btnDialNumber_Click

End Sub


:

Glad to hear it is working. It was totally untested.
Put that code in the Current event of the form.

:

Your code is working well.
The call is complete when the person goes to the next record. How can I
place your "Call Complete" code so it appears when the user moves to the next
record, i.e. open next record or leave current record? They move to the next
record by using the next record arrow in the bottom left of the frame.

:

Private dtmCallTime as Date ' Form Level variable

In the Click event of the DailButton:

dtmCallTime = timeserial(0,0,0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

In the Timer event of the form

Private Sub Form_Timer()
Dim dtmTimeCheck as Date

dtmTimeCheck = TimeSerial(0,3,0)
dtmCallTime = DateAdd("s",1,dtmCallTime)
Me.txtCall Duration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
Iif(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

You will also need to reset everything after a call is complete. Put this
right after you complete the call:

Me.txtCallDuration.BackColor = RGB(255,255,255)
Me.TimerInterval = 0
:

I create:
tbxCallTimer = 0
Me.tbxCallTimer = Timer

How do I update this every second?
I tried the property format of nn:ss, but that did not give me 02:12 for 2
minutes 12 seconds as Ihad hoped.

:

Here is a basic concept.
In the Click event of DialButton set the value of the Call Timer text box to
00:00 and start a timer event that will update the Timer text box every
second. And in the Change event of the Call Timer text box, change the back
color when it's value is = "00:00"

:

A2003
I have people who loose track of how long they are on a call.

1) They would like to have a timer on the form showing how long it has been
since the user pressed the DialButton - counting up the min:sec would be
fine.
2) If time is greater than 3 minutes they would like the color of min:sec to
change to red.

Thanks
 
Rod,
As I promised, I looked at this over the weekend, and here is what I came up
with. Since I did not take the original code home with me, this doesn't look
much like the original posting.
What I have done is created 2 module level variables, one to keep track of
whether a call is in place and one to display the call time.
I also made a modification to the Dial command button so that if the Caption
is "Dial", it zeros the timer, sets blnKeepingTime to True, and changes the
caption to "Hang Up". I think you will find this useful to the users so they
can stop the call when they need to. It also prevents them from restarting
the call which would reset the timer. This code also causes the call textbox
to flase red/white when it reaches 3 minutes. There is also code in the
Current event that reset the time and turns time keeping off in preparation
for the next call

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 Command27_Click()
If Me.Command27.Caption = "Dial" Then
Me.Command27.Caption = "Hang UP"
blnKeepingTime = True
dtmCallTime = TimeSerial(0, 0, 0)
Me.Text9.BackColor = RGB(255, 255, 255)
Me.Text9 = Format(dtmCallTime, "nn:ss")
Else
Me.Text9.BackColor = RGB(255, 255, 255)
Me.Command27.Caption = "Dial"
blnKeepingTime = False
End If
End Sub

Private Sub Form_Current()
Me.Command27.Caption = "Dial"
blnKeepingTime = False
dtmCallTime = TimeSerial(0, 0, 0)
Me.Text9.BackColor = RGB(255, 255, 255)
Me.Text9 = Format(dtmCallTime, "nn:ss")
End Sub

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

Private Sub Form_Timer()
If blnKeepingTime Then
dtmCallTime = DateAdd("s", 1, dtmCallTime)
Me.Text9 = Format(dtmCallTime, "nn:ss")
If Minute(dtmCallTime) >= 3 Then
If Me.Text9.BackColor = RGB(255, 255, 255) Then
Me.Text9.BackColor = RGB(255, 0, 0)
Else
Me.Text9.BackColor = RGB(255, 255, 255)
End If
End If
End If
End Sub


Rod said:
No problem. I have learned a lot working with you. Anxiously awaiting your
reply...

Klatuu said:
Rod,
I forgot something important. Access Help says to set the timer interval in
the Load event of the form. Since it is not resetting and running correctly,
I will need to play with it and trick it. I know I can do it, I did it
several years ago, but I don't remember exactly how. I will play with it
over the weekend, and get back to you.

My apologies for wasting your time chasing this problem. Once I get all the
egg off my face, I will get it fixed and get back to you.

Rod said:
The clock is running from zero. It starts when I move to the next record
regardless if I press the dial button. It needs to only start when I press
the button. I have the code in the right location, but something is kicking
it off regardless. Pressing the dial button does not even reset the clock -
something os overriding the dial button statement to start the clock.

:

In the current event, you are setting the timer interval to 1 second. You
need to set it to 0. Then you set it to 1000 in the Button Click event to
start it.

:

It resets the clock, but the clock starts without me pressing the dial button
when I advance the record. Here is a copy of what I have and where the key
components are in the editor:

Option Compare Database
Private dtmCallTime As Date ' Form Level variable
Private Sub Form_Timer()
Dim dtmTimeCheck As Date

dtmTimeCheck = TimeSerial(0, 3, 0)
dtmCallTime = DateAdd("s", 1, dtmCallTime)
Me.txtCallDuration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
IIf(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

Private Sub Form_Current()
'next record. This will reset the clock.
dtmCallTime = TimeSerial(0, 0, 0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

End Sub

Private Sub btnDialNumber_Click()
On Error GoTo Err_btnDialNumber_Click

Dim stDialStr As String
Dim PrevCtl As Control
Const ERR_OBJNOTEXIST = 2467
Const ERR_OBJNOTSET = 91
Const ERR_CANTMOVE = 2483

Set PrevCtl = Screen.PreviousControl

Me.Text131 = DLookup("[Msg]", "tblScripts", "[ID] = " & Me.Frame124)
CALLED_ON = Date
CALL_RESULTS = "Message"

Me.tbxMsgToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON] =
" & Format(Date, "\#mm\/dd\/yyyy\#") & " And [CALL_RESULTS] = 'Message'"), 0)
Me.tbxCallsToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON]
= " & Format(Date, "\#mm\/dd\/yyyy\#")), 0)

Select Case [RESUME]
Case -1
Frame124 = 1
Case 0
Frame124 = 8
End Select

Application.Run "utility.wlib_AutoDial", tbxDIALNUMBER

Exit_btnDialNumber_Click:
Exit Sub

Err_btnDialNumber_Click:
If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Or (Err =
ERR_CANTMOVE) Then
Resume Next
End If
MsgBox Err.Description
Resume Exit_btnDialNumber_Click

End Sub


:

Glad to hear it is working. It was totally untested.
Put that code in the Current event of the form.

:

Your code is working well.
The call is complete when the person goes to the next record. How can I
place your "Call Complete" code so it appears when the user moves to the next
record, i.e. open next record or leave current record? They move to the next
record by using the next record arrow in the bottom left of the frame.

:

Private dtmCallTime as Date ' Form Level variable

In the Click event of the DailButton:

dtmCallTime = timeserial(0,0,0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

In the Timer event of the form

Private Sub Form_Timer()
Dim dtmTimeCheck as Date

dtmTimeCheck = TimeSerial(0,3,0)
dtmCallTime = DateAdd("s",1,dtmCallTime)
Me.txtCall Duration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
Iif(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

You will also need to reset everything after a call is complete. Put this
right after you complete the call:

Me.txtCallDuration.BackColor = RGB(255,255,255)
Me.TimerInterval = 0
:

I create:
tbxCallTimer = 0
Me.tbxCallTimer = Timer

How do I update this every second?
I tried the property format of nn:ss, but that did not give me 02:12 for 2
minutes 12 seconds as Ihad hoped.

:

Here is a basic concept.
In the Click event of DialButton set the value of the Call Timer text box to
00:00 and start a timer event that will update the Timer text box every
second. And in the Change event of the Call Timer text box, change the back
color when it's value is = "00:00"

:

A2003
I have people who loose track of how long they are on a call.

1) They would like to have a timer on the form showing how long it has been
since the user pressed the DialButton - counting up the min:sec would be
fine.
2) If time is greater than 3 minutes they would like the color of min:sec to
change to red.

Thanks
 
OK, a few question about your code:
1) I copied the code and received the error: "Ambiguous name
detected:Form_Timer
2) What is Command27.Caption?
3) What is blnKeepingTime
4) I noticed you have two: Private Sub Form_Timer()
I'm just trying to understand what you have done so I can adapt my form to
fit your code.

Thanks much for your help.

Klatuu said:
Rod,
As I promised, I looked at this over the weekend, and here is what I came up
with. Since I did not take the original code home with me, this doesn't look
much like the original posting.
What I have done is created 2 module level variables, one to keep track of
whether a call is in place and one to display the call time.
I also made a modification to the Dial command button so that if the Caption
is "Dial", it zeros the timer, sets blnKeepingTime to True, and changes the
caption to "Hang Up". I think you will find this useful to the users so they
can stop the call when they need to. It also prevents them from restarting
the call which would reset the timer. This code also causes the call textbox
to flase red/white when it reaches 3 minutes. There is also code in the
Current event that reset the time and turns time keeping off in preparation
for the next call

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 Command27_Click()
If Me.Command27.Caption = "Dial" Then
Me.Command27.Caption = "Hang UP"
blnKeepingTime = True
dtmCallTime = TimeSerial(0, 0, 0)
Me.Text9.BackColor = RGB(255, 255, 255)
Me.Text9 = Format(dtmCallTime, "nn:ss")
Else
Me.Text9.BackColor = RGB(255, 255, 255)
Me.Command27.Caption = "Dial"
blnKeepingTime = False
End If
End Sub

Private Sub Form_Current()
Me.Command27.Caption = "Dial"
blnKeepingTime = False
dtmCallTime = TimeSerial(0, 0, 0)
Me.Text9.BackColor = RGB(255, 255, 255)
Me.Text9 = Format(dtmCallTime, "nn:ss")
End Sub

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

Private Sub Form_Timer()
If blnKeepingTime Then
dtmCallTime = DateAdd("s", 1, dtmCallTime)
Me.Text9 = Format(dtmCallTime, "nn:ss")
If Minute(dtmCallTime) >= 3 Then
If Me.Text9.BackColor = RGB(255, 255, 255) Then
Me.Text9.BackColor = RGB(255, 0, 0)
Else
Me.Text9.BackColor = RGB(255, 255, 255)
End If
End If
End If
End Sub


Rod said:
No problem. I have learned a lot working with you. Anxiously awaiting your
reply...

Klatuu said:
Rod,
I forgot something important. Access Help says to set the timer interval in
the Load event of the form. Since it is not resetting and running correctly,
I will need to play with it and trick it. I know I can do it, I did it
several years ago, but I don't remember exactly how. I will play with it
over the weekend, and get back to you.

My apologies for wasting your time chasing this problem. Once I get all the
egg off my face, I will get it fixed and get back to you.

:

The clock is running from zero. It starts when I move to the next record
regardless if I press the dial button. It needs to only start when I press
the button. I have the code in the right location, but something is kicking
it off regardless. Pressing the dial button does not even reset the clock -
something os overriding the dial button statement to start the clock.

:

In the current event, you are setting the timer interval to 1 second. You
need to set it to 0. Then you set it to 1000 in the Button Click event to
start it.

:

It resets the clock, but the clock starts without me pressing the dial button
when I advance the record. Here is a copy of what I have and where the key
components are in the editor:

Option Compare Database
Private dtmCallTime As Date ' Form Level variable
Private Sub Form_Timer()
Dim dtmTimeCheck As Date

dtmTimeCheck = TimeSerial(0, 3, 0)
dtmCallTime = DateAdd("s", 1, dtmCallTime)
Me.txtCallDuration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
IIf(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

Private Sub Form_Current()
'next record. This will reset the clock.
dtmCallTime = TimeSerial(0, 0, 0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

End Sub

Private Sub btnDialNumber_Click()
On Error GoTo Err_btnDialNumber_Click

Dim stDialStr As String
Dim PrevCtl As Control
Const ERR_OBJNOTEXIST = 2467
Const ERR_OBJNOTSET = 91
Const ERR_CANTMOVE = 2483

Set PrevCtl = Screen.PreviousControl

Me.Text131 = DLookup("[Msg]", "tblScripts", "[ID] = " & Me.Frame124)
CALLED_ON = Date
CALL_RESULTS = "Message"

Me.tbxMsgToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON] =
" & Format(Date, "\#mm\/dd\/yyyy\#") & " And [CALL_RESULTS] = 'Message'"), 0)
Me.tbxCallsToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON]
= " & Format(Date, "\#mm\/dd\/yyyy\#")), 0)

Select Case [RESUME]
Case -1
Frame124 = 1
Case 0
Frame124 = 8
End Select

Application.Run "utility.wlib_AutoDial", tbxDIALNUMBER

Exit_btnDialNumber_Click:
Exit Sub

Err_btnDialNumber_Click:
If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Or (Err =
ERR_CANTMOVE) Then
Resume Next
End If
MsgBox Err.Description
Resume Exit_btnDialNumber_Click

End Sub


:

Glad to hear it is working. It was totally untested.
Put that code in the Current event of the form.

:

Your code is working well.
The call is complete when the person goes to the next record. How can I
place your "Call Complete" code so it appears when the user moves to the next
record, i.e. open next record or leave current record? They move to the next
record by using the next record arrow in the bottom left of the frame.

:

Private dtmCallTime as Date ' Form Level variable

In the Click event of the DailButton:

dtmCallTime = timeserial(0,0,0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

In the Timer event of the form

Private Sub Form_Timer()
Dim dtmTimeCheck as Date

dtmTimeCheck = TimeSerial(0,3,0)
dtmCallTime = DateAdd("s",1,dtmCallTime)
Me.txtCall Duration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
Iif(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

You will also need to reset everything after a call is complete. Put this
right after you complete the call:

Me.txtCallDuration.BackColor = RGB(255,255,255)
Me.TimerInterval = 0
:

I create:
tbxCallTimer = 0
Me.tbxCallTimer = Timer

How do I update this every second?
I tried the property format of nn:ss, but that did not give me 02:12 for 2
minutes 12 seconds as Ihad hoped.

:

Here is a basic concept.
In the Click event of DialButton set the value of the Call Timer text box to
00:00 and start a timer event that will update the Timer text box every
second. And in the Change event of the Call Timer text box, change the back
color when it's value is = "00:00"

:

A2003
I have people who loose track of how long they are on a call.

1) They would like to have a timer on the form showing how long it has been
since the user pressed the DialButton - counting up the min:sec would be
fine.
2) If time is greater than 3 minutes they would like the color of min:sec to
change to red.

Thanks
 
Rod said:
OK, a few question about your code:
1) I copied the code and received the error: "Ambiguous name
detected:Form_Timer
This is because you have 2 Form_Timer events in you code.
2) What is Command27.Caption?
Command27 is the name of the command button that starts and ends call
timeing. For you , it would be your Dial command button. You just need to
change the names. Also notice that I wrote it so the user can stop the call
without moving off the record so they can do any additional data entry needed
after they hang up.
3) What is blnKeepingTime
This is a boolean (Yes/No) data type variable used to know whether to update
the time display. Since we need to keep the timer running while the form is
open, we have to know how to handle it. If blnKeepingTime is = True, a call
is in progress and we update the time display; otherwise, we do not.
4) I noticed you have two: Private Sub Form_Timer()
Reviewing my post, I don't see two Private Sub From_Timer() events. Maybe
you copied it in twice. This is why you are getting the ambiguous name error
I'm just trying to understand what you have done so I can adapt my form to
fit your code.

See below for detailed explanations.
Thanks much for your help.
***********************************************
New Answers Start Here
This sub fires when you click on the Dial command button. Change the names
to suit your form.Here we use the button's caption (what displays on the form) to determine
whether a call is in progress. If it says Dail, then we start a call.Initializes the call time variable to 0. See the TimeSerial function in VBA
Help for more infoDisplays the call time variable in the time display text box formatted to
display minutes and secondsThe call is now at least 3 minutes in duration
This If statement causes the time display to flash red and white. Because
we are doing it every time the timer event fires, it will change colors every
second
If Me.Text9.BackColor = RGB(255, 255, 255) Then
Me.Text9.BackColor = RGB(255, 0, 0)
Else
Me.Text9.BackColor = RGB(255, 255, 255)
End If
End If
End If
End Sub


Rod said:
No problem. I have learned a lot working with you. Anxiously awaiting your
reply...

:

Rod,
I forgot something important. Access Help says to set the timer interval in
the Load event of the form. Since it is not resetting and running correctly,
I will need to play with it and trick it. I know I can do it, I did it
several years ago, but I don't remember exactly how. I will play with it
over the weekend, and get back to you.

My apologies for wasting your time chasing this problem. Once I get all the
egg off my face, I will get it fixed and get back to you.

:

The clock is running from zero. It starts when I move to the next record
regardless if I press the dial button. It needs to only start when I press
the button. I have the code in the right location, but something is kicking
it off regardless. Pressing the dial button does not even reset the clock -
something os overriding the dial button statement to start the clock.

:

In the current event, you are setting the timer interval to 1 second. You
need to set it to 0. Then you set it to 1000 in the Button Click event to
start it.

:

It resets the clock, but the clock starts without me pressing the dial button
when I advance the record. Here is a copy of what I have and where the key
components are in the editor:

Option Compare Database
Private dtmCallTime As Date ' Form Level variable
Private Sub Form_Timer()
Dim dtmTimeCheck As Date

dtmTimeCheck = TimeSerial(0, 3, 0)
dtmCallTime = DateAdd("s", 1, dtmCallTime)
Me.txtCallDuration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
IIf(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

Private Sub Form_Current()
'next record. This will reset the clock.
dtmCallTime = TimeSerial(0, 0, 0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

End Sub

Private Sub btnDialNumber_Click()
On Error GoTo Err_btnDialNumber_Click

Dim stDialStr As String
Dim PrevCtl As Control
Const ERR_OBJNOTEXIST = 2467
Const ERR_OBJNOTSET = 91
Const ERR_CANTMOVE = 2483

Set PrevCtl = Screen.PreviousControl

Me.Text131 = DLookup("[Msg]", "tblScripts", "[ID] = " & Me.Frame124)
CALLED_ON = Date
CALL_RESULTS = "Message"

Me.tbxMsgToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON] =
" & Format(Date, "\#mm\/dd\/yyyy\#") & " And [CALL_RESULTS] = 'Message'"), 0)
Me.tbxCallsToday = Nz(DCount([CALLED_ON], "tblCandidates", "[CALLED_ON]
= " & Format(Date, "\#mm\/dd\/yyyy\#")), 0)

Select Case [RESUME]
Case -1
Frame124 = 1
Case 0
Frame124 = 8
End Select

Application.Run "utility.wlib_AutoDial", tbxDIALNUMBER

Exit_btnDialNumber_Click:
Exit Sub

Err_btnDialNumber_Click:
If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Or (Err =
ERR_CANTMOVE) Then
Resume Next
End If
MsgBox Err.Description
Resume Exit_btnDialNumber_Click

End Sub


:

Glad to hear it is working. It was totally untested.
Put that code in the Current event of the form.

:

Your code is working well.
The call is complete when the person goes to the next record. How can I
place your "Call Complete" code so it appears when the user moves to the next
record, i.e. open next record or leave current record? They move to the next
record by using the next record arrow in the bottom left of the frame.

:

Private dtmCallTime as Date ' Form Level variable

In the Click event of the DailButton:

dtmCallTime = timeserial(0,0,0)
Me.TimerInterval = 1000 ' Sets interval to 1 second.

In the Timer event of the form

Private Sub Form_Timer()
Dim dtmTimeCheck as Date

dtmTimeCheck = TimeSerial(0,3,0)
dtmCallTime = DateAdd("s",1,dtmCallTime)
Me.txtCall Duration = Format(dtmCallTime, "nn:ss")
If dtmCallTime >= dtimTimeCheck Then
Me.txtCallDuration.BackColor = _
Iif(Me.txtCallDuration.BackColor = RGB(255, 0, 0), _
RGB(255, 255, 255), RGB(255, 0, 0))
End If

End Sub

You will also need to reset everything after a call is complete. Put this
right after you complete the call:

Me.txtCallDuration.BackColor = RGB(255,255,255)
Me.TimerInterval = 0
:

I create:
tbxCallTimer = 0
Me.tbxCallTimer = Timer

How do I update this every second?
I tried the property format of nn:ss, but that did not give me 02:12 for 2
minutes 12 seconds as Ihad hoped.

:

Here is a basic concept.
In the Click event of DialButton set the value of the Call Timer text box to
00:00 and start a timer event that will update the Timer text box every
second. And in the Change event of the Call Timer text box, change the back
color when it's value is = "00:00"

:

A2003
I have people who loose track of how long they are on a call.

1) They would like to have a timer on the form showing how long it has been
since the user pressed the DialButton - counting up the min:sec would be
fine.
2) If time is greater than 3 minutes they would like the color of min:sec to
change to red.

Thanks
 
Back
Top