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