Is It Possible To Have a Default Value When Using [] For Input?

  • Thread starter Thread starter mcl
  • Start date Start date
M

mcl

When using [] for ask for user input in a query, is it possible to display a
default value?
I tried [Enter Min Value,Default] and that of course didn't work.
 
mcl said:
When using [] for ask for user input in a query, is it possible to display a
default value?
I tried [Enter Min Value,Default] and that of course didn't work.
Not immediately.

You can invoke the query from code, and pass a parameter to it. You can
ask the user for the parameter value with InputBox() which *has* a
default value possibility.

Is it an action query? Then you can use this piece of air:

dim qd as querydef
dim cVal as string
cval = inputbox("your question",,"default")
if cval<>"" then ' if user chooses Cancel, the result is ""
set qd=currentdb.querydefs("yourquery")
qd.parameters(0) = cval
qd.execute
end if
 
AFAIK, this level of control is not available with a
parameter query. It can easily be implemented, however,
using an unbound form. The user enters criteria into the
form's controls, and presses a command button to open the
query or report.

In the query, enter the appropriate references to the
appropriate form controls, as in:

=Forms!yourformname!yourcontrolname

HTH
Kevin Sprinkel
-----Original Message-----
When using [] for ask for user input in a query, is it possible to display a
default value?
I tried [Enter Min Value,Default] and that of course
didn't work.
 
The closest you can come without using a form is to use

Val(NZ([Enter Min Value, Blank = 5],5))

You have much more control if you use a control on a form to do this.
 
Thanks, I tried your suggestion and it works fine.

John Spencer (MVP) said:
The closest you can come without using a form is to use

Val(NZ([Enter Min Value, Blank = 5],5))

You have much more control if you use a control on a form to do this.
When using [] for ask for user input in a query, is it possible to display a
default value?
I tried [Enter Min Value,Default] and that of course didn't work.
 
Back
Top