|
-
May 17th, 2016, 08:41 AM
#1
Thread Starter
Enjoy the moment
[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
Last edited by salsa31; May 17th, 2016 at 09:04 AM.
-
May 17th, 2016, 10:07 AM
#2
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
-
May 17th, 2016, 03:01 PM
#3
Thread Starter
Enjoy the moment
Re: After Update ,Total Hours Only Calculate 2 fields instead of 4 fields why?
 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?
-
May 18th, 2016, 06:43 AM
#4
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])
-
May 18th, 2016, 10:34 AM
#5
Thread Starter
Enjoy the moment
Re: After Update ,Total Hours Only Calculate 2 fields instead of 4 fields why?
 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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|