[RESOLVED] After Update ,Total Hours Only Calculate 2 fields instead of 4 fields why?
hey,
i have a punch clock that users punch in and out
they can punch in twice and punch out twice
when i update and try to calculate the total hours
it updates only 2 fields [EnterIN] [EnterOut]
instead of [EnterIN] [EnterOut] [EnterIN1] [EnterOut2] why?
i know that the update is ok i dont get any errors at all
this is my code
Code:
Dim Rs As New ADODB.Recordset
Rs.Open "Select * From EnterWork where EnterName='" & RplS(CmbName.Text) & "' AND EnterDate = #" & StrDate & "#", CN
If Not IsNull(Rs!EnterIN1) Then
StrSql = "UPDATE Enterwork SET "
StrSql = StrSql & "EnterOut2 = '" & RplS(LblTheTime.Caption) & "',"
StrSql = StrSql & "EnterRemarks = '" & RplS(TxtRemarks.Text) & "'"
StrSql = StrSql & " WHERE EnterID = " & Rs!EnterID
CN.Execute StrSql
Dim TimeDiff As Long
Dim StartDate As Date
Dim EndDate As Date
EndDate = Time
TimeDiff = DateDiff("n", StartDate, EndDate)
CN.Execute "Update Enterwork SET [EnterTotal]=DateDiff(""n"", [EnterIn],[EnterOut],[EnterIN1],[EnterOut2]) WHERE [EnterID]= " & Rs!EnterID
Rs.Close
Unload Me
Exit Sub
End If
Rs.Close
tnx for any help
salsa 31 :)
Re: After Update ,Total Hours Only Calculate 2 fields instead of 4 fields why?
well, first off... it only updates ONE field, EnterTotal ... second, I'm surprised you don't get an error because DateDiff only takes three parameters, the interval, the start date and the end date... so I don't even see how you're passing 5 and it "works"
-tg
Re: After Update ,Total Hours Only Calculate 2 fields instead of 4 fields why?
Quote:
Originally Posted by
techgnome
well, first off... it only updates ONE field, EnterTotal ... second, I'm surprised you don't get an error because DateDiff only takes three parameters, the interval, the start date and the end date... so I don't even see how you're passing 5 and it "works"
-tg
i know strange
what do suggest for me sir to do?
how can i acomplish this to work right?
Re: After Update ,Total Hours Only Calculate 2 fields instead of 4 fields why?
For the set, you may want to try something like this.
Code:
SET [EnterTotal]=DateDiff(""n"", [EnterIn],[EnterOut]) + DateDiff(""n"", [EnterIN1],[EnterOut2])
Re: After Update ,Total Hours Only Calculate 2 fields instead of 4 fields why?
Quote:
Originally Posted by
MarkT
For the set, you may want to try something like this.
Code:
SET [EnterTotal]=DateDiff(""n"", [EnterIn],[EnterOut]) + DateDiff(""n"", [EnterIN1],[EnterOut2])
Thank you very much Mark :)