Query Results into RecordSet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Just need to know how to put results from a query (as in listed in the Queries window) into a RecordSet for some additional processing...
 
You may want to save the query for subsequent processing.


Sid said:
Just need to know how to put results from a query (as in listed in the
Queries window) into a RecordSet for some additional processing...
 
What I'm having trouble with is the syntax for setting up a RecordSet such that it's content is the output from a query (rather than explicitly specifying the SQL in a variable).
 
Can't you use the query designer to design the query and copy the SQL.
Maybe I misunderstand you. Anyone listening, feel free to jump in.

Sid said:
What I'm having trouble with is the syntax for setting up a RecordSet such
that it's content is the output from a query (rather than explicitly
specifying the SQL in a variable).
 
Thank you for the help. You're getting it -- and I'll use your suggestion as my "work around" if there isn't any way to accomplish what I asked about. I was hoping to be able to use the Query Editor to fine tune the query once it is in place. It's rather long and convoluted and that seemed less error-prone and easier to re-verify than making changes in my twisted SQL directly. Thanks again -- the question is still on the table ..

Sid
 
Use QueryDef object:

Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
Set qd = CurrentDb.QueryDefs("YourQuery")
Set rs = qd.OpenRecordset

Hope this is what you are looking for.

Alex.

Sid said:
Thank you for the help. You're getting it -- and I'll use your suggestion
as my "work around" if there isn't any way to accomplish what I asked about.
I was hoping to be able to use the Query Editor to fine tune the query once
it is in place. It's rather long and convoluted and that seemed less
error-prone and easier to re-verify than making changes in my twisted SQL
directly. Thanks again -- the question is still on the table ...
 
Sid said:
Just need to know how to put results from a query (as in listed in
the Queries window) into a RecordSet for some additional
processing...

You can simply open a (DAO) recordset using CurrentDb.OpenRecordset:

Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset("YourQueryName")

' ... do stuff with rs ...

rs.Close
Set rs = Nothing
 
Back
Top