Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to accumulate data in a variable

Status
Not open for further replies.

merlynsdad

Programmer
Nov 18, 2010
175
US
I'm pulling logon and logoff times for employees. I have a loop that pulls the employee, then another loop inside that pulls all the logon and logoff times for that employee, record by record.There can be multiple signons/signoffs in a day. Where I'm running into trouble is that I need to accumulate all the logon and logoff times for each employee in a variable, store that somewhere, then clear the variable and go to the next employee. The code (so far) looks like this:

For each Employee in rst1
Do While Not rst1.EOF
With rst1
QryLoc = rst1![acd]

If event_type = 2 then
datSignon = time_stamp
ElseIf event_type = 3 then
datSignoff = time_stamp
ElseIf event_type = 4 then
datIdle = time_stamp
End if

datReadyTime = ((datSignoff - datSignon)-datIdle) '
Loop
datReadyTime = datReadyTimeStoredByEmployee
datReadyTime = ""
Next Employee

I'm not sure about the datReadyTimeStoredByEmployee at all, and am looking for a better way to do this. Suggestions, please?



If the square peg won't fit in the round hole, sand off the corners.
 


hi,
Code:
    Dim sPrevEmp As String
    With rst1
       Do While Not .EOF
          QryLoc = rst1![acd]
          
          If event_type = 2 Then
             datSignon = time_stamp
          ElseIf event_type = 3 Then
             datSignoff = time_stamp
          ElseIf event_type = 4 Then
             datIdle = time_stamp
          End If
    
          datReadyTime = ((datSignoff - datSignon) - datIdle)     '
          '[b]
          sPrevEmp = .fields("Employee").Value
          .movenext
          
          If sPrevEmp = .fields("Employee").Value Then
            '???
          Else
            '???
          End If
       Loop
       '[/b]
    End With


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top