there is no query to do this. 1 row cannot see another row.
you need vb code. Date and time should have been in 1 single field.
something like:
Code:
Public Sub CalcElapse()
Dim rst 'As Recordset
Dim sSql As String
Dim bPrev As Boolean, bIn As Boolean
sSql = "select * from table"
Set rst = CurrentDb.OpenRecordset(sSql)
bPrev = False
With rst
While Not .EOF
vDat = .Fields("Date")
vTim = .Fields("time")
vio = .Fields("checktype")
bIn = (vio = "I")
Select Case True
Case bIn And bPrev
'error 2 INs
GoTo skipIt
Case bIn And Not bPrev
vStart = vDat & " " & vTim
Case Not bIn And bPrev
vEnd = vDat & " " & vTim
Case Not bIn And Not bPrev
'error 2 OUTs
GoTo skipIt
End Select
vElaps = DateDiff("n", vStart, vEnd)
If vEnd Then Debug.Print vStart, vEnd, vElaps
vPrev = vIn
skipIt:
.MoveNext
Wend
End With
Set rst = Nothing
End Sub