Default Values for Query Parameters

  • Thread starter Thread starter Ethan
  • Start date Start date
E

Ethan

G'day,
I have a query which sorts by the user entered
parameters,

between [Start Date] and [End Date]

However, most often, but not allways, I use the same
dates. Is there a way to continue to have the query prompt
for start and end dates, but have a pre-entered default
value, so that I can just hit enter most of the time?

Thanks in advance.
-Ethan
 
G'day,
I have a query which sorts by the user entered
parameters,

between [Start Date] and [End Date]

However, most often, but not allways, I use the same
dates. Is there a way to continue to have the query prompt
for start and end dates, but have a pre-entered default
value, so that I can just hit enter most of the time?

Thanks in advance.
-Ethan

Try it this way:

Where [ADate] between [Start Date] and [End Date] Or [ADate] Between
IIf(IsNull([Start Date]), #1/1/2004#) and #3/31/2004#;

You'll need to click OK on both empty parameter prompts to get the
default dates.
 
Not using a straigth parameter query, no. However if you create a small
form with textboxes to hold the values and reference these textboxes in the
query, then yes you can.

On my website (see sig below) is a small sample database called
"ParaQuerySelect.mdb" which illustrates how to do this.
 
fredg said:
G'day,
I have a query which sorts by the user entered
parameters,

between [Start Date] and [End Date]

However, most often, but not allways, I use the same
dates. Is there a way to continue to have the query prompt
for start and end dates, but have a pre-entered default
value, so that I can just hit enter most of the time?

Thanks in advance.
-Ethan

Try it this way:

Where [ADate] between [Start Date] and [End Date] Or [ADate] Between
IIf(IsNull([Start Date]), #1/1/2004#) and #3/31/2004#;

You'll need to click OK on both empty parameter prompts to get the
default dates.


Why both with the Or, Fred?

Where [ADate] Between IIf(IsNull([Start Date]), #1/1/2004#) And
IIf(IsNull([End Date]), #3/31/2004#)

should be sufficient
 
Why both with the Or, Fred?

Where [ADate] Between IIf(IsNull([Start Date]), #1/1/2004#) And
IIf(IsNull([End Date]), #3/31/2004#)

should be sufficient

or even

BETWEEN Nz([Start Date], DateSerial(Year(Date()), 1, 1) AND NZ([End
Date], DateSerial(Year(Date()), 12, 31))
 
Back
Top