Query Results into RecordSet

S

Sid

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...
 
P

Phil Hunt

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...
 
S

Sid

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).
 
P

Phil Hunt

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).
 
S

Sid

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
 
A

Alex Ivanov

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 ...
 
D

Dirk Goldgar

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top