determining parameters

hog

Registered User.
Local time
Yesterday, 22:06
Joined
Jan 24, 2005
Messages
14
I have a form with 5 fields on it. I want the user to enter as many or as few parameters as they require to pull up their results from a query that will run when they click 'start search'

Problem is this...

How do I create the query so that if a parameter is or is not supplied?

Example;

Location could be London or Cardiff
Part could be specific or all

If London was selected and no part entered it would return all london parts

If no Location was entered but a part was the details of that part at both locations would be returned.

If neither location or part was entered then all parts for all locations would be returned.

But how do I set the criteria up on the query to deal with this??
 
Try this

I sent you an part of a database I use to make this kind of query with parameters.
I can't send you the tables, but the forms should give you an idea. Look at the code behind the form and the AttacherString sub in the ModGeneral module.
 

Attachments

Hi,

thanks for this, but struggling to make sense of it as it is in French! me no speako da lingo!
 
I often create such unbound forms from which to run reports.

for fields that I don't want to specify, I create a default value on the form that catches all records. For instance, I have a db that tracks calls from Me & two other reps. all calls are placed to a Rep Code Rep1, Rep2, or Rep3. When I write the query - it states Rep =>[forms]![Rep Report]![Rep Start] and =<[Forms]![Rep Report]![Rep Finish]. The default value for Rep Start is Rep1, the default value for Rep Finish is Rep3.

The above assumes that you already know how to write a query that references an unbound form in order to run a report.....
 
hog said:
Hi,

thanks for this, but struggling to make sense of it as it is in French! me no speako da lingo!

Oops, I forgot to translate!
 

Users who are viewing this thread

Back
Top Bottom