This was working yesterday, but I've obviously changed something that was seemingly unrelated.:banghead::banghead::banghead:
When using an SQL string with .OpenRecordset, I can use
"WHERE [COLLATEDATE]<=Date();"
without issue, but when I use
"WHERE (Month([COLLATEDATE])<=Month(Date()));"
my code crashes.
I've confirmed that the 'COLLATEDATE' field is definitely saved as a date datatype, and I've checked that my string works when I use it in the SQL view of a normal Access query, but I can't think of any other esoteric issues that might be causing this to fail.
Here's what the complete recordset query is meant to be:
When using an SQL string with .OpenRecordset, I can use
"WHERE [COLLATEDATE]<=Date();"
without issue, but when I use
"WHERE (Month([COLLATEDATE])<=Month(Date()));"
my code crashes.
I've confirmed that the 'COLLATEDATE' field is definitely saved as a date datatype, and I've checked that my string works when I use it in the SQL view of a normal Access query, but I can't think of any other esoteric issues that might be causing this to fail.
Here's what the complete recordset query is meant to be:
Code:
Dim StrSQL as String
StrSQL = "SELECT tbl_SHAPETemp.COLLATEDATE AS TestDate, tbl_SHAPETemp.WBS, tbl_SHAPETemp.[RAW HOURS] AS TestDuration " & _
FROM tbl_SHAPETemp " & _
WHERE (((Month([COLLATEDATE]))<=Month(Date())) AND ((Year([COLLATEDATE]))<=Year(Date()))) OR (((Month([COLLATEDATE]))>Month(Date())) AND ((Year([COLLATEDATE]))<Year(Date())));"
Creates query containing all older entries
Set OlderRecords = CurrentDb.OpenRecordset(strSQL)