parameter query

C

Christina

Hi,
I have a parameter query that prompts for 3 different criteria. One being
between one date and another date. I want the query to return data on the
other criteria and return all dates if I dont put the dates in the last
criteria. Hope someone can help me. Thanks

Christina
 
A

Allen Browne

So you want the parameter to NOT limit the query results if it is left
blank?

That's doable, but somewhat messy. Switch the query to SQL View, and set up
the WHERE clause like this:
SELECT * FROM Table1
WHERE ((ClientID = [WhatClient]) OR ([WhatClient] Is Null))
AND ((SaleDate >= [StartDate]) OR ([StartDate] Is Null))
AND ((SaleDate <= [EndDate]) OR ([EndDate] Is Null));

Once you get serious with Access, you tend to use that pop-up parameter
dialog only rarely. Users like it better if you provide a form where they
can enter all the parameter values, and click a button to open the report or
filter the form or wherever the query results are going. This take a bit of
work to code, but it is a technique worth learning.

For an example, see:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html
The article contains an example you can download and play with, and an
explanation of the query approach.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top