Parameter query

  • Thread starter Thread starter Ray
  • Start date Start date
R

Ray

Is it possible to have a parameter query where I select the options from a
list rather than typing the options? If so, may I know how to construct it.

Thanks,

Ray
 
On a form use a ComboBox or ListBox to select from.
In the query use criteria --
[Forms]![YourForm]![YourComboBox]
OR
[Forms]![YourForm]![YourListBox]

Use a macro or event in your ComboBox or ListBox to open the query.
 
Karl,

Thanks for your useful advice that resolves my issue.

Is it possible to show all records if I do not enter/select any item in the
combo box?

Ray

KARL DEWEY said:
On a form use a ComboBox or ListBox to select from.
In the query use criteria --
[Forms]![YourForm]![YourComboBox]
OR
[Forms]![YourForm]![YourListBox]

Use a macro or event in your ComboBox or ListBox to open the query.
Ray said:
Is it possible to have a parameter query where I select the options from
a
list rather than typing the options? If so, may I know how to construct
it.

Thanks,

Ray
 
In the criteria, use a bit extra like:

[Forms]![YourForm]![YourComboBox] OR
([Forms]![YourForm]![YourComboBox] Is Null)

(type as *one line is the criteria row).
 
Use these to get all without selecting any --
Like [Forms]![YourForm]![YourComboBox] &"*"
OR
Like [Forms]![YourForm]![YourListBox] &"*"


Ray said:
Karl,

Thanks for your useful advice that resolves my issue.

Is it possible to show all records if I do not enter/select any item in the
combo box?

Ray

KARL DEWEY said:
On a form use a ComboBox or ListBox to select from.
In the query use criteria --
[Forms]![YourForm]![YourComboBox]
OR
[Forms]![YourForm]![YourListBox]

Use a macro or event in your ComboBox or ListBox to open the query.
Ray said:
Is it possible to have a parameter query where I select the options from
a
list rather than typing the options? If so, may I know how to construct
it.

Thanks,

Ray
 
Karl & Van,

Thanks for your useful advice and believe both are working to my request.
However, it does not work if I open the combo box form and hit Enter. I
need to enter something and delete it and then hit Enter to display all
records. Is it correct to put the event into After Update event procedure
or other more appropriate event for this application? Currently I use macro
to open a report that linked the said query in preview mode.

Ray


Ray said:
Karl,

Thanks for your useful advice that resolves my issue.

Is it possible to show all records if I do not enter/select any item in
the combo box?

Ray

KARL DEWEY said:
On a form use a ComboBox or ListBox to select from.
In the query use criteria --
[Forms]![YourForm]![YourComboBox]
OR
[Forms]![YourForm]![YourListBox]

Use a macro or event in your ComboBox or ListBox to open the query.
Ray said:
Is it possible to have a parameter query where I select the options from
a
list rather than typing the options? If so, may I know how to construct
it.

Thanks,

Ray
 
Normally, I use a CommandButton to execute the Query. As you have
discovered, using the AfterUpdate Event of the ComboBox means that there
must be some action in the ComboBox to trigger the AfterUpdate.
 
Van,

Thanks for your reply. Using CommandButton is a bit inconvenient. How can
I hit a space bar and then hit Enter to drive the query to show all records?

Ray
 
If you want to use Enter, you can simply set the Default Property of the
CommandButton to True.

Alternatively or to use SpaceBar, you can set the KeyPreview Property of the
Form to True and then use the Form_KeyPress Event to check the Key pressed
and execeute the Query if required.

Check Access VB Help on the special terms I mantioned above.
 
Van,

Many thanks for your useful advice.

Ray

Van T. Dinh said:
If you want to use Enter, you can simply set the Default Property of the
CommandButton to True.

Alternatively or to use SpaceBar, you can set the KeyPreview Property of
the Form to True and then use the Form_KeyPress Event to check the Key
pressed and execeute the Query if required.

Check Access VB Help on the special terms I mantioned above.
 
Back
Top