Results 1 to 5 of 5

Thread: [RESOLVED] After Update ,Total Hours Only Calculate 2 fields instead of 4 fields why?

  1. #1

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Resolved [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.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: After Update ,Total Hours Only Calculate 2 fields instead of 4 fields why?

    Quote Originally Posted by techgnome View Post
    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?

  4. #4
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    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])

  5. #5

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: After Update ,Total Hours Only Calculate 2 fields instead of 4 fields why?

    Quote Originally Posted by MarkT View Post
    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
  •  



Click Here to Expand Forum to Full Width