May 09 2022 07:49 AM
has anyone had this?
trying to set in VBA code the following:
dim rs as recordset
set rs = db.openrecordset("SomeQuery")
the query has criteria of a boolean set to true and sorted to Forms!SomeForm!SomeID
and some date criteria.
the query itself is working when running it with out vba but i cant call it by a record set from VBA, it is showing up as rs=null
May 10 2022 10:54 AM - edited May 10 2022 10:54 AM
One of the best ways to actually get responsive help is to be verbose in providing information and context about a problem.
What is the SQL in that query? What is the boolean criteria; where and how is it set? What is that "some date criteria"? Where is it set and how?
One of the problems with calling SQL from VBA is that you have to be adamant about providing the parameters needed. i.e. make them explicit, don't assume VBA will find them in the SQL in a saved query.
On a final note. It is Good Practice to fully reference objects when dimming them. In the old days, we got away with less discipline. These days, it is not so safe.
I.e.
Dim rs as DAO.Recordset (or if you are actually using ADO, use that explicitly).
Dim db as DAO.Database