Parameters

T

TheCaptain

This is my first database and it is pretty basic. My question is:

I am using multiple parameters in a form. The formis linked to a query by
way of a button and using (design view) Criteria: Between [Forms]![Rental
Search].[sqfrom] And [Forms]![Rental Search].[sqto]

--- This gives me a range to search in. My problem is because I have
multiple parameters I have to enter data into each one. I do not want to do
this all the time. I want to be able to search using only one parameter, but
different ones for different searches, to retrieve records.

I am thinking I have to add a command to the Or section under Criteria, but
I don't know what.

Thanks
 
R

Ryan

A good way to solve this problem is to duplicate the Criteria field, and in
the first Criteria field, do a greater than date, and in the second Criteria
fild, do a less than date. You would also allow each criteria to be blank.
Here is an example.

Criteria1:IIf([Forms]![RentalSearch].[sqfrom] Is
Null,[Criteria1],>=[Forms]![RentalSearch].[sqfrom])

Criteria2:IIf([Forms]![RentalSearch].[sqto] Is
Null,[Criteria2],<=[Forms]![RentalSearch].[sqto])

Here is what Criteria2 says. If the sqto field is null, then show all
records, but if it has a date in it show all dates <= less than or equal the
date entered. This allows to leave one or both fields blank. If the sqto
field was blank and the sqFrom had 7/1/2008 in it then all records for
7/1/2008 and older would be shown. I hope this helps you out.
 

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