i have a timepunch clock that users punch in and out
i created also a table called EnterWorkHistory
now when a user punches in the clock i have a code that insert also in the EnterWorkHistory
when the user punchesout the clock i need to be the same in the EnterWorkHistory
how ever i get alot of errors when i try to update also the EnterWorkHistory
i cant figure it out
this is the code that i have
when a user punches in
when a user punches out- this is the code that makes me errors :confused:
this is the code that a user punch in
this is the code the user punches out
![Name: New Bitmap Image.jpg
Views: 14
Size: 33.5 KB]()
![Name: A.jpg
Views: 12
Size: 34.5 KB]()
i know i messed up the code
that is why i ask for help
i created also a table called EnterWorkHistory
now when a user punches in the clock i have a code that insert also in the EnterWorkHistory
when the user punchesout the clock i need to be the same in the EnterWorkHistory
how ever i get alot of errors when i try to update also the EnterWorkHistory
i cant figure it out
this is the code that i have
when a user punches in
Code:
Dim NewID As Long
NewID = NextID("ID", "EnterWorkHistory")
strSQL = "INSERT INTO EnterWorkHistory "
strSQL = strSQL & "(ID,HistDate, HistDay, HistName, HistIN)"
strSQL = strSQL & "VALUES("
strSQL = strSQL & NewID & ","
strSQL = strSQL & "#" & MyDate(PickDate.Value) & "#,"
strSQL = strSQL & "'" & RplS(Txt(1).text) & "',"
strSQL = strSQL & "'" & RplS(CmbName.text) & "',"
strSQL = strSQL & "'" & RplS(Txt(2).text) & "'"
strSQL = strSQL & ")"
CN.Execute strSQL
Code:
Dim TimeDiff As Long
Dim StartDate As Date
Dim EndDate As Date
Dim rsL As ADODB.Recordset
Set rsL = New ADODB.Recordset
'rsL.Open "Select EnterIN from Enterwork where EnterID=" & Frmtime.LsVw.SelectedItem.Tag, CN, adOpenForwardOnly, adLockOptimistic
'If rsL.EOF Then
'MsgBox "No logins found"
'Else
'StartDate = rsL(0)
EndDate = Time
TimeDiff = DateDiff("n", StartDate, EndDate)
CN.Execute "Update EnterWorkHistory SET [HisTotal]=DateDiff(""n"", [EnterIn],[EnterOut]) WHERE [EnterID]=" & Frmtime.LsVw.SelectedItem.Tag
Unload Me
Frmtime.LoadList
Code:
Dim NewID As Long
NewID = NextID("EnterID", "Enterwork")
strSQL = "INSERT INTO Enterwork "
strSQL = strSQL & "(EnterID, EnterDate, EnterDay, EnterName, EnterIN)"
strSQL = strSQL & "VALUES("
strSQL = strSQL & NewID & ","
strSQL = strSQL & "#" & MyDate(PickDate.Value) & "#,"
strSQL = strSQL & "'" & RplS(Txt(1).text) & "',"
strSQL = strSQL & "'" & RplS(CmbName.text) & "',"
strSQL = strSQL & "'" & RplS(Txt(2).text) & "'"
strSQL = strSQL & ")"
CN.Execute strSQL
Set itm = Frmtime.LsVw.ListItems.Add(, , Frmtime.LsVw.ListItems.Count + 1, , "logkey")
itm.Tag = NewID
itm.SubItems(1) = Replace$(PickDate.Value, ",", ".")
itm.SubItems(2) = Replace$(Txt(1).text, ",", ".")
itm.SubItems(3) = Replace$(CmbName.text, ",", ".")
itm.SubItems(4) = Replace$(Txt(2).text, ",", ".")
Code:
With Frmtime.LsVw.SelectedItem
strSQL = "UPDATE Enterwork SET "
strSQL = strSQL & "EnterOut = '" & RplS(Txt(2).text) & "',"
strSQL = strSQL & "EnterRemarks = '" & RplS(Txt(0).text) & "'"
strSQL = strSQL & " WHERE EnterID = " & Frmtime.LsVw.SelectedItem.Tag
CN.Execute strSQL
.SubItems(5) = Txt(2).text
.SubItems(6) = Txt(0).text
Dim TimeDiff As Long
Dim StartDate As Date
Dim EndDate As Date
Dim rsL As ADODB.Recordset
Set rsL = New ADODB.Recordset
rsL.Open "Select EnterIN from Enterwork where EnterID=" & Frmtime.LsVw.SelectedItem.Tag, CN, adOpenForwardOnly, adLockOptimistic
If rsL.EOF Then
MsgBox "No logins found"
Else
StartDate = rsL(0)
EndDate = Time
TimeDiff = DateDiff("n", StartDate, EndDate)
CN.Execute "Update Enterwork SET [EnterTotal]=DateDiff(""n"", [EnterIn],[EnterOut]) WHERE [EnterID]=" & Frmtime.LsVw.SelectedItem.Tag
End If
End With
End If
Unload Me
Frmtime.LoadList
i know i messed up the code
that is why i ask for help