How to daisy chain queries and use the output from one query as parameter for another

  • Thread starter Thread starter Karen Middleton
  • Start date Start date
K

Karen Middleton

Hello All

I want to daisy chain a few queries the situation I have is the
following:


Query1
Query2
Query3
Query4

I want to use the output generated from the Query1 as a parameter for
Query2 and the value generated from Query2 as a parameter for
Query3,etc


I tried using the following to daisy chain the queries:

CurrentDb().QueryDefs("Query1").Execute


Appears this cannot be done since the above VBA code cannot execute a
Select query it can run a insert, update or delete query but not a
Select query.

Query1 is something like this:

Select sum(val)/Count(*) from Tab1;

I want to use the value of sum(val)/count(*) called as tempresult in
the following:

select * from tab2 where val2 >= tempresult;


Please clarify how I can accomplish using the following approach:

CurrentDb().QueryDefs("Query1").Execute


Please explain how I can run a Select query from the above code and
use the output into a temporary variable and pass it to the second
query as a parameter.

Thanks
Karen
 
Back
Top