Variable dates in queries

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I run ten queries each week , each of them has a variable
(date) that needs to be changed before i run the query.
This means that I have to go into each of the ten queries
and manually change the date.

Is there a way that I could change the date in one place
and ask the query to look to that place to find out what
the variable has changed to ?

Thanks
 
Steve,

There are two possibilities that I am aware of.

You could create a form that you launch the queries from. On the form you
would add a textbox where you would enter the date you wish the queries to
be based on. You would then need to modify the queries to use the field on
your form instead of a hard coded date.

I understand there is also away to have the query ask for a parameter when
you run it, although I don't know what the syntax is for that.

Hope this helps.

Larry
 
There is at least 3 ways:
1) Add the date field as a parameter to all of your
queries. If In access sql just do so,ething like:

Select * from table where table_date = [parameter Date];

make sure you use teh same parameter name through out all
of your queries, so that you only have to enter oone date!
Then when you run it you'll be prompted for a [Parameer Date] !

2) Create a form for you to type in the Date field and then
use the vba.replace funcion to replace the inputed Date.

3) Using a parameter Query...

4) Use DAO or ADO and changing the SQL directly, but it is
analogous to step 2 above.

I'd recommend option 1. Easy & simplest!

good luck

Acie
 
Back
Top