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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending parameters to a query

Status
Not open for further replies.

LionSkyWalker

Programmer
May 9, 2001
8
0
0
MX
Hi there, I have a little doubt:


I have a report, it works with a query,
But my doubt is, how could I send parameters to that query from a form???

or

How could I request for those parameters before I open the report???

I hope u can help me.
 
Lion:

What you are describing is pretty simple.

Create an unbound form (not linked to any table -- call it frmCriteria) and put controls on that form to allow the user to enter/select the query criteria you want to use.

For example, if you are setting up a date range query, put two text boxes on the form (call them txtStart and txtEnd) and format them for short date. Put a command button on the form to open the desired report.

Open the query in design view and in the criteria cell for the date to be searched enter:

>=Forms!frmCriteria.txtStart And <= Forms!frmCriteria.txtEnd

When the user opens frmCriteria they enter the starting and ending dates and click on the command button to open the report. The report will open the query to get the data for the report and the query will look at the two text boxes on frmCriteria for the date range.

I know it sounds like circular logic, but it works.


Larry De Laruelle
larry1de@yahoo.com

 
Rather than using the >= and <= try this:

Between [Forms]![frmCriteria]![txtStart] and [Forms]![frmCriteria]![txtEnd]

It's a little bit easier to remember than the greater than, less than stuff.

Joe Miller
joe.miller@flotech.net
 
To prompt a user when the report runs, enter the following for the criteria of the query (this example would prompt for a start date and end date):

between [Enter start date] and [Enter end date]

This will put up two simple dialog boxes, and the text will read what is between the square brackets. If you're using dates, it's pretty forgiving on how the users enter the dates.

Dan
 
Thanx, it worked with &quot;between [Enter start date] and [Enter end date]&quot;

And it wasn't so complicated.

See u
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top