Connecting Tech Pros Worldwide Forums | Help | Site Map

How to create pause command

Newbie
 
Join Date: Oct 2007
Posts: 12
#1: Dec 11 '07
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.

Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#2: Dec 11 '07

re: How to create pause command


What have you tried so far?
Newbie
 
Join Date: Oct 2007
Posts: 12
#3: Dec 12 '07

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.
Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#4: Dec 12 '07

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?
jaxjagfan's Avatar
Expert
 
Join Date: Dec 2007
Location: Jax, FL
Posts: 253
#5: Dec 12 '07

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:
Expand|Select|Wrap|Line Numbers
  1. 'Created with buttons (cmdLogin,cmdLogOff)
  2. 'Created toggle (togPause)
  3. 'Created text boxes to test
  4. 'Used ontimer event to give employee 30 sec updates on work time
  5. Option Compare Database
  6. Dim bkBegin, bkEnd, bkTime, totTime, totBegin, totEnd, wkTime, empID
  7.  
  8. Private Sub cmdLogin_Click()
  9. '-------------------------
  10. totBegin = Now()
  11. 'Capture EmployeeID
  12. empID = "E01"
  13. UpdateTXT 'update the display
  14. '-------------------------
  15. End Sub
  16.  
  17. Function UpdateTXT()
  18. '-------------------------
  19. Me.txtEmpID = empID
  20. Me.txtLoginTime = totBegin
  21. Me.txtLogOutTime = totEnd
  22. Me.txtWorkTime = wkTime
  23. Me.txtBreakTime = bkTime
  24. '-------------------------
  25. End Function
  26.  
  27. Private Sub cmdLogOff_Click()
  28. '-------------------------
  29. 'Employee can logoff system and login later
  30. totEnd = Now()
  31. totTime = (totEnd - totBegin)
  32. '-------------------------
  33. 'Time spent working
  34. wkTime = (totTime - bkTime)
  35. '-------------------------
  36. 'Update work table with work session
  37. 'Insert Into tblWork (EmployeeID,WorkBegin,WorkEnd,BreakTime,TotalTime,WorkTime)
  38. 'VALUES (empID,totBegin,totEnd,totTime,wkTime)
  39. '-------------------------
  40. UpdateTXT 'update the display
  41. '-------------------------
  42. End Sub
  43.  
  44. Private Sub Form_Timer()
  45. '-------------------------
  46. 'Set Time Interval to 30000 (30 secs) in form properties
  47. 'Update display for employee to see current work time every 30 secs
  48. txtCheckTime = (totTime - bkTime)
  49. '-------------------------
  50. End Sub
  51.  
  52. Private Sub togPause_Click()  'Employee break(pause)
  53. '-------------------------
  54. If Me.togPause = -1 Then
  55. bkBegin = Now()
  56. Me.togPause.Caption = "On Break"
  57. Else: Me.togPause.Caption = "At Work"
  58. bkEnd = Now()
  59. bkTime = bkTime + (bkEnd - bkBegin)
  60. UpdateTXT 'update the display
  61. End If
  62. '-------------------------
  63. End Sub
  64.  
Newbie
 
Join Date: Oct 2007
Posts: 12
#6: Jan 23 '08

re: How to create pause command


Oh finally its work perfect. Thank you so much jax :)
Newbie
 
Join Date: Oct 2007
Posts: 12
#7: Mar 14 '08

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
Reply


Similar Microsoft Access / VBA bytes