Here is vb code to scan and post the results
Code:
'sort the data in the sql, vb code scans list joining the dates
'then posts to a output table2
Public Sub DateJoin()
Dim rst
Dim vEmp, vDate1, vDate2, vDateStart, vDateEnd, vPrevEmp
Dim lTot As Long, lVal As Long
Dim sSql As String
vPrevEmp = ""
sSql = "select * from tbl order by [empID],[StartDate]"
Set rst = CurrentDb.OpenRecordset(sSql)
With rst
While Not .EOF
vEmp = .Fields("[empID]") & ""
lVal = .Fields("[Working Days]")
vDate1 = .Fields("[StartDate]")
vDate2 = .Fields("[EndDate]")
If vEmp <> vPrevEmp And vPrevEmp <> "" Then
vEndDate = vDate2
'-----------------------
'post THE total...
'-----------------------
sSql = "insert into table2 ([empid],[startDate],[EndDate],TotalDays) values (" & vPrevEmp & ",#" & vDateStart & "#,#" & vDateEnd & "#," & lTot & ")"
DoCmd.RunSQL sSql
lTot = 0
vDateStart = vDate1
End If
lTot = lTot + lVal
vPrevEmp = vEmp
.MoveNext
Wend
End With