Don't you hate it when a program worked last month and now it fails.
I have an Access procedure that executes this (counts rows in the table with the matching date):
StrSearchCriteria = "SELECT Ticker " _
& "FROM FundMonthlyDetailAllHistory " _
& "WHERE AsOfDate = #" & DDate & "#; "
rs.Open StrSearchCriteria, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
i = 1
Do Until rs.EOF
i = i + 1
rs.MoveNext
Loop
rs.Close
This works great; no problem.
About 300 lines down the procedure I have this:
StrSearchCriteria = "SELECT Ticker, FundStatus, Category, AsOfDate " _
& "FROM FundMonthlyDetailCurrent " _
& "ORDER BY Category, FundStatus"
rs.Open StrSearchCriteria, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
StrCategory = " "
i = 1
Do Until rs.EOF
If StrCategory = rs!Category Then
i = i + 1
Else
i = 1
End If
rs!CurrentRank = i
StrCategory = rs!Category
DDate = rs!AsOfDate ' save the As of Date for later processing
rs.MoveNext
Loop
rs.Close
This sorts and counts rows by "Category".
The loop never ends because it appears the open fails, although Access seems to think everything is fine for the open. If I try to check the value of rs.Category in the Immediate window with ?rs.Category I receive a "run timer error 3704" "Operation not allowed when the object is closed"
I have verified that the table has the data as expected and that the code was not changed since last month's run of the procedure.
I decided to try last month's data again - and this also failed at the same code.
Any thoughts are appreciated? Windows/Access update maybe? I'm at a loss.