Hi,
Am having problems with date search in recordset. I am trying to extract data from a table filed depending if it is between two dates.
With code below the recordset populates with the correct records and the do while loop steps through the records but the if statement is not working to select records within the date range.
The code below is only the part that is not working.
Const strJetDate = "\#mm\/dd\/yyyy\#" is at the top of the code.
Dim tbAnnual As DAO.Database
Dim rstAnnual As DAO.Recordset
Dim rstAnnualsearch As DAO.Recordset
Set tbAnnual = CurrentDb
ADayCount = 0
strFindDate1 = Format(txAtADate, strJetDate)
strFindDate2 = Format(strAEndDate, strJetDate)
Set rstAnnual = tbAnnual.OpenRecordset("tbAnnual", dbOpenDynaset)
rstAnnual.Filter = "ANameIndex = '" & strEmpId & " '"
Set rstAnnualsearch = rstAnnual.OpenRecordset()
With rstAnnualsearch
Do While Not .EOF
If !AStartDate >= " & strFindDate1 & " And !AStartDate <= " & strFindDate2 & " Then
ADayCount = ADayCount + !ADays
End If
.MoveNext
Loop
End With