How to create pause command | Newbie | | Join Date: Oct 2007
Posts: 12
| | |
Hello All,
I have created a page with timer for the employee. They need to click start and stop button when doing their work. I want to have a pause button so when they going for break or anything they can just click the pause then once back they click the play button and the timer continue. Anyone can help me with the code. Thank you.
|  | Expert | | Join Date: Jan 2007 Location: California
Posts: 3,835
| | | re: How to create pause command
What have you tried so far?
| | Newbie | | Join Date: Oct 2007
Posts: 12
| | | re: How to create pause command Quote:
Originally Posted by Rabbit What have you tried so far? I have created a pause button. When click it stops but when we click paly it restarts the timer. It don't continue from where it stopped.
|  | Expert | | Join Date: Jan 2007 Location: California
Posts: 3,835
| | | re: How to create pause command Quote:
Originally Posted by abie16 I have created a pause button. When click it stops but when we click paly it restarts the timer. It don't continue from where it stopped. How are you storing the time? In a control on the form? In a global variable?
|  | Expert | | Join Date: Dec 2007 Location: Jax, FL
Posts: 253
| | | re: How to create pause command
What you need is (especially if hourly employees):
--TotalTime
--Pause (Breaks)
--WorkTime (TotalTime - TotalBreakTime)
I threw together a dirty form and come up with this: -
'Created with buttons (cmdLogin,cmdLogOff)
-
'Created toggle (togPause)
-
'Created text boxes to test
-
'Used ontimer event to give employee 30 sec updates on work time
-
Option Compare Database
-
Dim bkBegin, bkEnd, bkTime, totTime, totBegin, totEnd, wkTime, empID
-
-
Private Sub cmdLogin_Click()
-
'-------------------------
-
totBegin = Now()
-
'Capture EmployeeID
-
empID = "E01"
-
UpdateTXT 'update the display
-
'-------------------------
-
End Sub
-
-
Function UpdateTXT()
-
'-------------------------
-
Me.txtEmpID = empID
-
Me.txtLoginTime = totBegin
-
Me.txtLogOutTime = totEnd
-
Me.txtWorkTime = wkTime
-
Me.txtBreakTime = bkTime
-
'-------------------------
-
End Function
-
-
Private Sub cmdLogOff_Click()
-
'-------------------------
-
'Employee can logoff system and login later
-
totEnd = Now()
-
totTime = (totEnd - totBegin)
-
'-------------------------
-
'Time spent working
-
wkTime = (totTime - bkTime)
-
'-------------------------
-
'Update work table with work session
-
'Insert Into tblWork (EmployeeID,WorkBegin,WorkEnd,BreakTime,TotalTime,WorkTime)
-
'VALUES (empID,totBegin,totEnd,totTime,wkTime)
-
'-------------------------
-
UpdateTXT 'update the display
-
'-------------------------
-
End Sub
-
-
Private Sub Form_Timer()
-
'-------------------------
-
'Set Time Interval to 30000 (30 secs) in form properties
-
'Update display for employee to see current work time every 30 secs
-
txtCheckTime = (totTime - bkTime)
-
'-------------------------
-
End Sub
-
-
Private Sub togPause_Click() 'Employee break(pause)
-
'-------------------------
-
If Me.togPause = -1 Then
-
bkBegin = Now()
-
Me.togPause.Caption = "On Break"
-
Else: Me.togPause.Caption = "At Work"
-
bkEnd = Now()
-
bkTime = bkTime + (bkEnd - bkBegin)
-
UpdateTXT 'update the display
-
End If
-
'-------------------------
-
End Sub
-
| | Newbie | | Join Date: Oct 2007
Posts: 12
| | | re: How to create pause command
Oh finally its work perfect. Thank you so much jax :)
| | Newbie | | Join Date: Oct 2007
Posts: 12
| | | re: How to create pause command
Hi Jacx,
I have problem in updating the time to the text box. It displays error"method or data member not found".I have create the text box to take value but when i click the start button it displays the error.
Can you please assist me on this.
I have paste for you the code i have build.
Private Sub cmd_Start_act1_Click()
Set sw = New StopWatch
Module1.sw.StartTimer
totBegin = Now()
UpdateTXT 'update the display
cmd_stop_act1.Enabled = True
cmd_stop_act1.SetFocus
cmd_Start_act1.Enabled = False
'Making the text boxes visible after clicking the Queue
txtact1.Visible = True
lblact1.Visible = True
'Assigning Null value to the text box to avoid updating Null value
txtact1.Value = ""
'Enabling the Start Timer buttons
cmd_Start_act1.Enabled = True
'Enabling the Stop Timer Button
cmd_stop_act1.Enabled = True
'Disabling Queue list
lstQueue.Enabled = False
'Disabling Show Activity
cmdShow_Activity.Enabled = False
'Disabling Save Data
cmdSaveData.Enabled = False
cmd_stop_act1.Enabled = True
cmd_stop_act1.SetFocus
cmd_Start_act1.Enabled = False
End Sub
Function UpdateTXT()
'-------------------------
Me.txtLoginTime = totBegin
Me.txtLogOutTime = totEnd
'-------------------------
End Function
Private Sub cmd_stop_act1_Click()
Module1.sw.EndTimer
If txtact1.Value = "" Then
txtact1.Value = Round(Module1.time_taken, 2)
Else
txtact1.Value = txtact1.Value + Round(Module1.time_taken, 2)
End If
totEnd = Now()
UpdateTXT 'update the display
'Enabling Queue list
lstQueue.Enabled = True
'Enabling Save Activity TIme
cmdSaveData.Enabled = True
'Enabling Show Activity Button
cmdShow_Activity.Enabled = True
cmd_Start_act1.Enabled = True
cmd_Start_act1.SetFocus
cmd_stop_act1.Enabled = False
End Sub
|  | Similar Microsoft Access / VBA bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,510 network members.
|