MacSean
MacSean

Reputation: 251

Adding a default for a parameter query in MS Access 2007

I have a report query that asks users for two parameters. One of these parameters is a date. Is it possible to have a non-answer (i.e., the user presses the "OK" button without having entered a date) default to Today()? If so, how?

Upvotes: 1

Views: 11717

Answers (3)

Victor Petersen
Victor Petersen

Reputation: 51

The problem with Judah's solution is that it will always bring up items that meet the default value even when you enter a different one.

Try using the "Nz" function instead. For example, I entered the following into my "Criteria:" field:

Nz([Enter Date:], Date())

If the user enters a date, it uses that date. If the user doesn't, it uses today's date.

Hope that helps.

Upvotes: 5

Judah Sali
Judah Sali

Reputation: 1098

A better solution:

Set [What is the date?] as the first criteria, and Date() as the second (Or) criteria!

Upvotes: 0

Judah Sali
Judah Sali

Reputation: 1098

Assuming you are not using a form for entering your criteria,

In your query try this as the Criteria for the date field:

IIf(IsNull([What Is The Date?]),Date(),[What Is The Date?])

Upvotes: 5

Related Questions