By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,392 Members | 1,576 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,392 IT Pros & Developers. It's quick & easy.

is it possible to run a multiple level query in VBA?

P: 27
for example, i have 3 query levels...one bulids on the next.

Query1 returns some results to query2, query2 returns some results to query3, then i want to use the query3 data.

i would like to implement this in VBA instead of using the queries.

i know the standard way to run sql commands in VBA is similar to this:

dim sql as string

sql = "sql code here"
docmd.runsql (sql)

but how can you do multiple level queries in that manner?
Nov 30 '06 #1
Share this Question
Share on Google+
1 Reply


NeoPa
Expert Mod 15k+
P: 31,661
Are you talking about action queries?
Display queries (SELECT * FROM Table etc) cannot be invoked from DoCmd.RunSQL.

Sub-queries can be used within SQL using parentheses surrounding the sub-query.
Assigning a name to the sub-query is usual if referring to a field is required.
A simple display query which is equivalent to displaying a table 'tblThis' :
Expand|Select|Wrap|Line Numbers
  1. SELECT subQ.* FROM (SELECT * FROM tblThis) AS subQ
Nov 30 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.