Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing parameters in queries

Status
Not open for further replies.

netcert

Programmer
Apr 11, 2001
115
0
0
US
I have 3 queries I run in one macro. Each of them prompt the user for a date (which is the same date for all 3). I don't want the user to have to enter the same date all three times. Here's where my date param is coming into play: DateDiff("m",[join_date],[Enter a Date])

This is in the 3 queries and I'd like to be able to have the user to enter it once and then have the 1st query pass it to the other queries within this same expression or whatever if you have a better idea. I've tried making this one query by doing an "OR" statement but I get no data. So I'm stuck with 3 queries right now.

Thanks.

Rob
 
Rob,

You must store the value of the date entered somewhere. There are a few choices. If you want to stay with macros, here's what I suggest.

Create a new table that has 1 field only, a date field that will hold the value of the date entered by the user.
Create an update query on that table that has the [Enter a Date] in the critera.
Change your macro to run the update query before the other 3.
Change the 3 queries to lookup the date from that new table as a field in the query result.
Use that field for the 3rd argument in you DateDiff function.

Hope that works for you.
 
Rob,

You can also create a form with input date an refer the query to the field in the form.

In general, my experience is that if you give the "enter date" parameter in the queries exactly the same name (ie [Enter Date:]) the user will only have to enter it once.

EK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top