1

I'd like to make a reference to a recordset via SQL FROM statement. Example.

I have a Recordset called RS. What I want to do is the following, in VBA.

SELECT * FROM RS

Is there a way?

1
  • While you can't query a recordset using SQL, you can get recordsets based on recordsets using ADO and the MsDataShape OLE DB provider with its SHAPE syntax, known as hierarchical recordsets e.g. see support.microsoft.com/kb/185425 Commented Mar 17, 2011 at 8:54

2 Answers 2

2

In general, no. They are two different languages and environments. In order to use information from one in the other, you either have to use VBA to send data to SQL to process or extract data from SQL to be used by VBA to process. If you wanted to process this using SQL, there are numerous solutions the simplest of which is to populate a table in the database with the contents of your recordset and then use that table in your query.

Sign up to request clarification or add additional context in comments.

1 Comment

Okay, I'll use that one. Thaks a lot!
0

What kind of recordset do you have, DAO or ADO?

If you have a populated ADO recordset and you need only a subset of it, you can use RS.Find to find single rows which match a certain criteria, or RS.Filter to filter out every row which doesn't match a certain criteria.
Be aware that this only works with ADO recordsets, not DAO recordsets!

It' not exactly "Select * from RS", but maybe it helps you.

2 Comments

DAO, I think. But I need to refer to the recordset as if it were a table or query.
DAO has a feature that allows you to create a second recordset by filtering an existing recordset, but I can't think what use it is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.