User prompt between 2 dates used in multiple queries

sean98

New Member
Joined
Apr 4, 2002
Messages
26
I am running a query that pulls in data from three other queries. Each query pulls data from seperate tables. The tables represent data for each year. Each record in all tables contain a week number. I have prompted the user to input the week range they would like to pull data from (Between [Week 1] and [Week 2]). The query was built to pull comparable years data for the same weeks. Right now the user has to input the same weeks three times, one for each query. I would like the user to be able to input the data only once and have the other queries recognize these dates when running their information.

Any thoughts on how I can do this would be appreciated.

Cheers,
Sean
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Thanks for the insight Nate but I managed to trip over the answer when I was playing around. I just made sure each query had the same input names. Using the example I noted each query needed to run using the date range between weeks 1 and weeks 2 thus I put the same formula in each query under the week field ... between [Week 1] and [Week 2]

I hope this make sense for whomever might be looking at this.
 
Upvote 0
Sean,
One way to do this would be to have a form with two text boxes on it. Name them something like "txtStartDate" and "txtEndDate". In the Where Clause of your queries, remove the parameters that you have put on the dates and in their place, write:
Code:
Between Forms!Your_Form_With_The_Textboxes.Form!TxtStartDate AND Forms!Your_Form_With_The_Textboxes.Form!TxtEndDate
This will ensure that you only need to fill in the dates on your form one time for each query that calls those text boxes. You can also do some cool stuff like have a command button on the form which will automatically run the queries when you press, validate that the text in the text boxes are valid dates, etc. etc. etc.
 
Upvote 0

Forum statistics

Threads
1,221,544
Messages
6,160,431
Members
451,646
Latest member
mmix803

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