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

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
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,215,043
Messages
6,122,822
Members
449,096
Latest member
Erald

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