For the DoCmd.OpenQuery do you have to have a query saved when using VB?
Posted on 2014-01-13
I have a query in Access VB as follows:
strCurrentYear = "[Dues '" & Format(Now(), "yy") & "]"
strSQL = NormalSelect & " FROM Table1 " & _
"WHERE " & strCurrentYear & " <> 0 ORDER BY Last"
CurrentDb.QueryDefs("Membership").SQL = strSQL
It worked fine until 2014 hit. Then it still displayed last year's information. I tracked it down to the query that was saved as "Membership". In there was still the "Dues '13 <>0". Once I deleted that from the saved query the output was correct.
Seems as though I shouldn't have to do that. Is there a way to do this such that the advancing years will not have an impact?
For those that are wondering, NormalSelect is defined as "SELECT [First], [Last], Street, City, State, Zip, [Phone #] " just so I don't have to keep typing it over all the time.