Hello, I am needing to loop through records of employees with time take off dates and determine how many days off have been taken off in a row. For example, jDoe has dates 09/01/2016, 09/02/2016, 09/03/2016, 09/05/2016. I need to know that 3 days were taken off in a row. Below is the code and I am not sure how to change to account for the sequential days. Any help is appreciated.
Dim DB As Database
Dim rst As Recordset
Dim strsql As String
Dim EmplID_1 As String * 7, EmplID_2 As String * 7
Dim Dte_1 As Date, Dte_2 As Date
Dim count As Integer
Set DB = CurrentDb
strsql = "Select * from [Q316tbl-MonthThreeTimeOffFile] Order by [ID], [DateTaken];"
Set rst = DB.OpenRecordset(strsql, dbOpenDynaset)
count = 1
EmplID_1 = rst.Fields("ID").Value
Dte_1 = rst.Fields("DateTaken").Value
rst.Edit
rst.Fields("seq").Value = count
rst.Update
While Not (rst.EOF)
rst.MoveNext
EmplID_2 = rst.Fields("ID").Value
If ((EmplID_1 = EmplID_2) And (Dte_1 <> Dte_2)) Then count = count + 1 Else count = 1
rst.Edit
rst.Fields("Seq").Value = count
rst.Update
EmplID_1 = EmplID_2
Wend
Dim DB As Database
Dim rst As Recordset
Dim strsql As String
Dim EmplID_1 As String * 7, EmplID_2 As String * 7
Dim Dte_1 As Date, Dte_2 As Date
Dim count As Integer
Set DB = CurrentDb
strsql = "Select * from [Q316tbl-MonthThreeTimeOffFile] Order by [ID], [DateTaken];"
Set rst = DB.OpenRecordset(strsql, dbOpenDynaset)
count = 1
EmplID_1 = rst.Fields("ID").Value
Dte_1 = rst.Fields("DateTaken").Value
rst.Edit
rst.Fields("seq").Value = count
rst.Update
While Not (rst.EOF)
rst.MoveNext
EmplID_2 = rst.Fields("ID").Value
If ((EmplID_1 = EmplID_2) And (Dte_1 <> Dte_2)) Then count = count + 1 Else count = 1
rst.Edit
rst.Fields("Seq").Value = count
rst.Update
EmplID_1 = EmplID_2
Wend