Filter query from a query (1 Viewer)

Joy83

Member
Local time
Today, 14:40
Joined
Jan 9, 2020
Messages
101
here is my question
I have a report that uses a query (query 2)
Query 2 is actually using another to build up (query 1)
In the report load event there are few sqls that populate data in text boxed mainly using (query 2)

How to run the report in away that make sure that query 1 also get filtered too

example: query 1 filter the date

query 2 filter the products purchased in this date.

i need the two queries in my report . How to do that
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:40
Joined
May 7, 2009
Messages
16,419
you need to Add the Date from Query1 to your Query2, then you can
just filter Query2.
 

Joy83

Member
Local time
Today, 14:40
Joined
Jan 9, 2020
Messages
101
Thanks your reply
in the load event in the report I read a variable from a form which filters me query 2 and populate the report
I just noticed thar my report is reading a query that is depending on another query that I need to filter as well.
Is there any way that I can filter query 1 in the load first
So my query 2 can read the filtered query 1
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:40
Joined
Sep 21, 2011
Messages
10,561
Set tempvars and refer to them in the base query?
Need to do that in the form or perhaps open event of report.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:40
Joined
May 7, 2009
Messages
16,419
can you just make another Query that does not depend on Query1?
so you can just focus on filtering this New Query?
 

Joy83

Member
Local time
Today, 14:40
Joined
Jan 9, 2020
Messages
101
Set tempvars and refer to them in the base query?
Need to do that in the form or perhaps open event of report.
How to do this
I have the variable in the form
How to pass it and run it to the base query and execute it before I run the report ti make sure that i am reading correct data
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:40
Joined
Sep 21, 2011
Messages
10,561
You just set the tempvars with the correct data, then use them as criteria in the first query.
Only issue would be if that query is the base query for others that do not need/want that criteria.
 

Joy83

Member
Local time
Today, 14:40
Joined
Jan 9, 2020
Messages
101
You just set the tempvars with the correct data, then use them as criteria in the first query.
Only issue would be if that query is the base query for others that do not need/want that criteria.
That’s a good workarround
I can create another query for the other uses and specific one for this report

can u help me or maybe share a link or something
How to run a query from that temporary variable (form textbox) what would I write in the criteria that indicate that variable
 

jdraw

Super Moderator
Staff member
Local time
Today, 17:40
Joined
Jan 23, 2006
Messages
14,320
@Joy83
I recommend you show us some of your table and query structure.
Perhaps you could show your query sql; and a description of the data involved including the before and after you'd like with the filter.
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:40
Joined
Sep 21, 2011
Messages
10,561

Users who are viewing this thread

Top Bottom