Query Criteria

  • Thread starter Thread starter Steven P via AccessMonster.com
  • Start date Start date
S

Steven P via AccessMonster.com

Hello,
Is there a way to use a dropdown via a criteria expression? I have a
machine dropdown list that I would like to incorporate in a query expression
to avoid bad entries by operators. The method I am seeking would be similar
to entering [start date] and or [ending date] but being able to reference the
dropdown in the parameter box?
Thanks,
Steven
 
Dear Steven:

You cannot build anything into a query that creates a combo box (dropdown).
It will only ask for parameters in "text box" fashion.

Assiming your database is Jet (the default) you can reference a combo box on
any open form, however. So, if you use a form to open the query, place a
combo box for the desired value on the form. If the user has not made a
selection in the combo box, do you want the query to choose not to filter,
or do you want to inform the user the query cannot be run without making a
choice? Program the command button (or whatever opens the query) to respond
accordingly.

In the query, refer to the value in the combo box just like you would ask
for a parameter, but with this syntax:

[Forms]![FormName]![ControlName]

In the above, substitute the actual name of the form and control. The form
MUST be open, but if the query is only run from the command button on the
form, this is not an issue.

That should do it. Please let me know if this helped, and if I can be of
any other assistance.

Tom Ellison
 
Tom,
Thanks. I have done as you suggested and it partially works. The query does
not recognize the dropdown choice from the form. When I open the query by
itself it asks for the value, if I type it in the query runs as it should.
What do I need to do so the query actually references the dropdown choice
from the form?
Thanks,
Steven

Tom said:
Dear Steven:

You cannot build anything into a query that creates a combo box (dropdown).
It will only ask for parameters in "text box" fashion.

Assiming your database is Jet (the default) you can reference a combo box on
any open form, however. So, if you use a form to open the query, place a
combo box for the desired value on the form. If the user has not made a
selection in the combo box, do you want the query to choose not to filter,
or do you want to inform the user the query cannot be run without making a
choice? Program the command button (or whatever opens the query) to respond
accordingly.

In the query, refer to the value in the combo box just like you would ask
for a parameter, but with this syntax:

[Forms]![FormName]![ControlName]

In the above, substitute the actual name of the form and control. The form
MUST be open, but if the query is only run from the command button on the
form, this is not an issue.

That should do it. Please let me know if this helped, and if I can be of
any other assistance.

Tom Ellison
Hello,
Is there a way to use a dropdown via a criteria expression? I have a
[quoted text clipped - 7 lines]
Thanks,
Steven
 
Dear Steven:

The form on which the control exists must be open. The user must select a
value in that combo box so there is something on which the query can
operate. Finally, you must have spelled the references to the form and
control exactly. Then it should work.

Tom Ellison


Steven P via AccessMonster.com said:
Tom,
Thanks. I have done as you suggested and it partially works. The query
does
not recognize the dropdown choice from the form. When I open the query by
itself it asks for the value, if I type it in the query runs as it should.
What do I need to do so the query actually references the dropdown choice
from the form?
Thanks,
Steven

Tom said:
Dear Steven:

You cannot build anything into a query that creates a combo box
(dropdown).
It will only ask for parameters in "text box" fashion.

Assiming your database is Jet (the default) you can reference a combo box
on
any open form, however. So, if you use a form to open the query, place a
combo box for the desired value on the form. If the user has not made a
selection in the combo box, do you want the query to choose not to filter,
or do you want to inform the user the query cannot be run without making a
choice? Program the command button (or whatever opens the query) to
respond
accordingly.

In the query, refer to the value in the combo box just like you would ask
for a parameter, but with this syntax:

[Forms]![FormName]![ControlName]

In the above, substitute the actual name of the form and control. The
form
MUST be open, but if the query is only run from the command button on the
form, this is not an issue.

That should do it. Please let me know if this helped, and if I can be of
any other assistance.

Tom Ellison
Hello,
Is there a way to use a dropdown via a criteria expression? I have a
[quoted text clipped - 7 lines]
Thanks,
Steven
 
Tom,
YES!! I was referencing the label instead of the combo box, once corrected
it works great.
Thanks again. This site and people like you certainly have made my job a lot
easier, you are the best!
Steven

Tom said:
Dear Steven:

The form on which the control exists must be open. The user must select a
value in that combo box so there is something on which the query can
operate. Finally, you must have spelled the references to the form and
control exactly. Then it should work.

Tom Ellison
Tom,
Thanks. I have done as you suggested and it partially works. The query
[quoted text clipped - 42 lines]
 
Back
Top