View Full Version : IIF in Parameter Query


MikeG
06-06-2002, 11:49 AM
Is there a way to setup a parameter query so that if a user requests a specific year he/she would get that year's entries or if they type in ALL, they get all entries?
I've toyed with an IIF statement but haven't had much luck. I thought about setting it up as a BETWEEN/AND parameter query but wondered if there was something else available.

Sohaila Taravati
06-06-2002, 12:44 PM
There are several ways you can do that.
In your query where your date is you can put "Like [Enter Date:]" If the user puts in just a "*" they will get all of the dates and if they put in "3/*/*" they will get all the years in March.

You can also do this "Between [Enter begining date:] And [Enter Ending Date:]" this way they put in the whatever range they want http://www.access-programmers.co.uk/ubb/smile.gif

Sohaila

Jack Cowley
06-06-2002, 02:06 PM
Add a column to your query and set the field to something like this:

ByYear: Year([YourDateField])

In the criteria put these two lines one below the other:

[Forms]![YourForm]![YearField]
[Forms]![YourForm]![YearField]Is Null

Create a form and put an unbound field in it for the user to enter the date. Now they can enter a date in the field, click a command button and see the results. If they leave the field blank they will see all the records.