Use Date result from one query to filter another query

shaztastic73

New Member
Joined
Jun 22, 2021
Messages
4
Office Version
  1. 2019
Platform
  1. Windows
Hi, I have very basic VBA knowledge so please go easy on me :)

I have a query "qry_Data_Ref_Wk_Date" which returns a Min Date "ProcessDate".
I would like to use "ProcessDate" to apply an After Date Filter to another query "qry_Data_Filtered" by whatever means works best and stops me having to run the query qry_Data_Ref_Wk_Date copying ProcessDate and applying the After Date filter manually.....

I am really struggling with this and am not sure even where to start (think its got something to do with storing ProcessDate as a variable and then passing it on somehow), any help would be much appreciated.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I am a little confused, you mention VBA but only seem to be referring to Power Query which doesn't use VBA but uses the M Language.
If you are returning the ProcessDate to the spreadsheet ideally want to add one more step to the query "qry_Data_Ref_Wk_Date".
If you need the min value in the spreadsheet first create a new Reference query which continues on from that query.
Right click in the cell containing the min date and select Drill Down.
It sounds like you already have the filter line in the query "qry_Data_Filtered" it will most likely have something like #date(2021,3,5) in the formula in the formula bar. Replace that with the name of your min value query name. If you used the original query it will be "qry_Data_Ref_Wk_Date" otherwise it will be new reference query name.
 
Upvote 0
I am a little confused, you mention VBA but only seem to be referring to Power Query which doesn't use VBA but uses the M Language.
If you are returning the ProcessDate to the spreadsheet ideally want to add one more step to the query "qry_Data_Ref_Wk_Date".
If you need the min value in the spreadsheet first create a new Reference query which continues on from that query.
Right click in the cell containing the min date and select Drill Down.
It sounds like you already have the filter line in the query "qry_Data_Filtered" it will most likely have something like #date(2021,3,5) in the formula in the formula bar. Replace that with the name of your min value query name. If you used the original query it will be "qry_Data_Ref_Wk_Date" otherwise it will be new reference query name.
Sorry for any confusion caused but it's not and excel workbook its an access database.
 
Upvote 0
Not sure I get the whole picture, but you might get what you want by adding the 1st query to the 2nd query as you would a table and join on the date fields. This assumes you can join the date field from the 1st query to a date field in a table in the 2nd query. It also assumes there will be matching dates and that neither field contains time values. If that is not what you need then perhaps you need a subquery to get a date and use the result of the subquery as a date filter for the main (outer) query, which in this case would be qry_Data_Filtered. Perhaps for the second case, review
 
Upvote 0

Forum statistics

Threads
1,224,875
Messages
6,181,516
Members
453,050
Latest member
Obil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top