Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I set a default value for a parameter query? 2

Status
Not open for further replies.

Absalom

Technical User
Dec 26, 2002
4
US
Is there any way I can set a default value for the parameter part of a parameter query. If there was, then when a user left a parameter box empty there would still be the default value to fall back on.

Maintenance Planner in a Steel Mill
 
Well, you can use an expression in the criteria line like this

[Enter Value] Or [Enter Value] Is Null

With this expression, if they don't enter a value then all the records are returned.

HTH

Paul
 
You can use a criteria expression like:
Nz([Enter your favorite color],"Green")


Duane
MS Access MVP
 
That's worth a star from me. Tried a few variations on that but didn't get it.

Paul
 
Thanks dhookum,

The usage of Nz that you recommened works just fine for text but I couldn't get it to work for the date/time datatype. I tried each of the following. While I don't get an error, none of them returns any hits from the database.

Nz([Start Date],#1/1/2002#)
Nz([Start Date],"1/1/2002")
Nz([Start Date],1/1/2002)

Thanks

Maintenance Planner in a Steel Mill
 
My Bad,

This statement actually works just fine if I include the correct operators.

Nz([Start Date],"1/1/2002")

should be

>=Nz([Start Date],"1/1/2002")

Maintenance Planner in a Steel Mill
 
Actually you should probably use:
>=Nz([Start Date],#1/1/2002#)

Duane
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top