0

How do I add all time values in a database table to get its total, get the total tardiness then sum up to know how many days an employee is absent or present in a monthly basis?

2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by abelingaw
0

Here's what i have at the moment.

Private Sub Compute()

'lblhuam.Caption = DateTime.DateDiff("H", lbliam.Caption, lbloam.Caption)
'lblhupm.Caption = DateTime.DateDiff("H", lblipm.Caption, lblopm.Caption)

Dim Totam As String
Dim Totpm As String
Dim Totall As String

Con "Database.mdb"
With RecSet


    .Open "Select * from TimeLog where ID =" & Text1.Text, DBLink, adOpenKeyset, adLockPessimistic

    While .EOF = False
        
            lbldate.Caption = .Fields("DATE_LOG").Value
        
        If IsNull(.Fields("IN_AM")) = True Then
            lbliam.Caption = ""
        Else
            lbliam.Caption = .Fields("IN_AM").Value
        End If
        
         If IsNull(.Fields("OUT_AM")) = True Then
            lbloam.Caption = ""
        Else
            lbloam.Caption = .Fields("OUT_AM").Value
        End If
        
         If IsNull(.Fields("IN_PM")) = True Then
            lblipm.Caption = ""
        Else
            lblipm.Caption = .Fields("IN_PM").Value
        End If
        
        If IsNull(.Fields("OUT_PM")) = True Then
            lblopm.Caption = ""
        Else
            lblopm.Caption = .Fields("OUT_PM").Value
        End If
        
        Totall = Totpm + Totam
        
        Totam = Hour((.Fields("OUT_AM")) - (.Fields("IN_AM")))
        Totpm = Hour((.Fields("OUT_PM")) - (.Fields("IN_PM")))
        lblhuam.Caption = Totam
        lblhupm.Caption = Totpm
        lblmuam.Caption = Val(Totam) + Val(Totpm)
        
        .MoveNext
    
    Wend
    
    .Close

End With
DBLink.Close


End Sub

But it only computes the 2 fields. I would like to compute all the total hours of that employee for the whole 1 month.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.