Recording start and stop times on jobs

M

Michelle

Can you please have a look at the code below and tell me where I have gone
wrong.
I need to be able to log the start and stop times of each job and use those
times to calculate costing of job and payroll figs.
Am a virtual beginner at Access - based this code on another I was given for
a logon page.

Option Explicit
Dim dteStartJob As Time
Private Sub cmdStartJob_Click()
End Sub

Private Sub cmdStartJob_Click()
dteStartJob = Now
cmdStopJob.Visible = True
[AControl].SetFocus
cmdStartJob.Visible = False
End Sub

Private Sub cmdStopJob_Click()

Dim strSQL As String
strSQL = "Insert into tblJobTimes(TimeStartJob, TimeStopJob)Values (#" &
dteStartJob & "#,#" & Now & "#);"
CurrentDb.Execute strSQL, dbFailOnError
cmdStartJob.Visible = True
[AControl].SetFocus
cmdStopJob.Visible = False
End Sub
 
C

Chris B via AccessMonster.com

Try just using DateDiff,
you would need 3 text boxes one labled startjob and another stopjob or
similar, in the third put this code =DateDiff("n",[startjob],[stopjob])/60,
the entries into the two time boxes can just be HH.NN (NN refers to minutes
in access) format, this will give your result in hours and portion of hours
if it worked out any minutes, 2ndly if the job goes over midnight then you
simply enter the times with the apppropiate dates thus 'YYYY/MM/DD HH.NN'
This calculates the hours between the dates and times.
Can you please have a look at the code below and tell me where I have gone
wrong.
I need to be able to log the start and stop times of each job and use those
times to calculate costing of job and payroll figs.
Am a virtual beginner at Access - based this code on another I was given for
a logon page.

Option Explicit
Dim dteStartJob As Time
Private Sub cmdStartJob_Click()
End Sub

Private Sub cmdStartJob_Click()
dteStartJob = Now
cmdStopJob.Visible = True
[AControl].SetFocus
cmdStartJob.Visible = False
End Sub

Private Sub cmdStopJob_Click()

Dim strSQL As String
strSQL = "Insert into tblJobTimes(TimeStartJob, TimeStopJob)Values (#" &
dteStartJob & "#,#" & Now & "#);"
CurrentDb.Execute strSQL, dbFailOnError
cmdStartJob.Visible = True
[AControl].SetFocus
cmdStopJob.Visible = False
End Sub
 
Top