Forum Discussion
AMB_DATABASE
May 09, 2022Copper Contributor
Not getting any records by setting a record set from a query
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 For...
George_Hepworth
May 10, 2022Silver Contributor
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