Buidling query inside of a query using docmd.RunSQL.

  • Thread starter Thread starter thread
  • Start date Start date
T

thread

Hi all,

I need to build dinamic query but this query is based on 3 queries on
the way before reaching to this query
does anyone have an example of a query inside of a query?
i have a table that have data of some groups
there is a query for seperate group.
then all the groups query are build merged and making one query that
proccessing data from all of these groups
and last query that building a table from this proccessed query
i would like to make my database dynamic and not limit my groups
 
A query within a query is called a subquery. Here's an introductory article:
How to Create and Use Subqueries
at:
http://support.microsoft.com/?id=209066

If that gets too complex, and your final query still needs to use other
queries as input "tables", you can create the query statement you need for
the lower level query, and assign it to the SQL property of the QueryDef.
For example, if your final query uses Query1 as a table, you can use:
Dim db As DAO.Database
Dim strSql As String
Set db = CurrentDb
strSql = "SELECT * FROM Table2;"
db.QueryDefs("Query1").SQL = strSql
db.Exeute "Query2", dbFailOnError

For an explanation of why you might prefer the Execute method rather than
RunSQL, see:
Action queries: suppressing dialogs, while knowing results
at:
http://allenbrowne.com/ser-60.html
 

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

Back
Top