开发者

Adding a default for a parameter query in MS Access 2007

I have a report query that asks users for two parameters. One 开发者_JAVA技巧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?


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?])


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.


A better solution:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜