Public Sub BrowseQuery_DAO()

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim rst2 As DAO.Recordset
Dim strSQL As String
Dim strSQL2 As String
Dim CallingDate As Date
Dim i As Integer

Set dbs = CurrentDb()
i = 0


Set rst2 = CurrentDb.OpenRecordset("T_MaxMin")
CallingDate = rst2!MaxxDate


Do While Not rst2!MaxxDate - (i + 1) = rst2!MinnDate

strSQL2 = "SELECT COUNT(ID) AS [COUNTREPEAT]" & _
"FROM [repeat_detail] " & _
"WHERE OnlyDate between " & CallingDate - (i + 7) & _
" AND " & CallingDate - (i)

Set rst = CurrentDb.OpenRecordset(strSQL2)


Debug.Print rst2!MaxxDate - (i + 1) & ", repeated Count: " & rst![COUNTREPEAT]
i = i + 1

Loop

rst.Close
rst2.Close
dbs.Close
End Sub


'guys this code return zero for repeated count but the date loop is working
'i don't have any idea why its not reflecting the number of repeated records

'sample of the result
'5/13/2014, repeated Count: 0
'5/12/2014, repeated Count: 0