Dropdowns in Parameter queries

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can I create a Parameter query that uses a created combo/list box from the
database in the message that comes up when running the query?

I would like to create a query that prompts me to select an Employee's name
from a long list and then gives me ONLY data associated with the person.

For example, if I run the query, the first thing I should get is a message
box that says "Select the Employee", but instead of just typing the name in
manually (creating possibility for errors), it allows me to just select from
a pre-made list.

I am using Access 2002.
 
Can I create a Parameter query that uses a created combo/list box from the
database in the message that comes up when running the query?

I would like to create a query that prompts me to select an Employee's name
from a long list and then gives me ONLY data associated with the person.

For example, if I run the query, the first thing I should get is a message
box that says "Select the Employee", but instead of just typing the name in
manually (creating possibility for errors), it allows me to just select from
a pre-made list.

I am using Access 2002.

The below is fine if the query is the end result.
However, it's done a bit differently if the query is to be used as the
record source for a report. In which case, post back.

Create an unbound form.
Add a combo box.
Set the Row Source of the combo box to include the
EmployeeID field and the Employee Name.
Name the Combo Box 'cboFindEmployee'.

Set it's Bound column to 1.
Set it's Column Count property to 2.
Set the Column Width property to 0";1"
Set it's AutoExpand property to Yes.
Set it's LimitToList property to Yes.

Add a Command Button to the form.
Code the button's click event:

DoCmd.OpenQuery "QueryName"
Do.Cmd.Close acForm, Me.Name

Name this form 'ParamForm'.

On the query's [EmployeeID] field criteria line write:
forms!ParamForm!cboFindEmployee

When you wish to run the query, open the form (not the query).
Select the Employee. Click the Command Button.
The query will display and the form will close.
 
Yes, I want to use the query to run a report

fredg said:
Can I create a Parameter query that uses a created combo/list box from the
database in the message that comes up when running the query?

I would like to create a query that prompts me to select an Employee's name
from a long list and then gives me ONLY data associated with the person.

For example, if I run the query, the first thing I should get is a message
box that says "Select the Employee", but instead of just typing the name in
manually (creating possibility for errors), it allows me to just select from
a pre-made list.

I am using Access 2002.

The below is fine if the query is the end result.
However, it's done a bit differently if the query is to be used as the
record source for a report. In which case, post back.

Create an unbound form.
Add a combo box.
Set the Row Source of the combo box to include the
EmployeeID field and the Employee Name.
Name the Combo Box 'cboFindEmployee'.

Set it's Bound column to 1.
Set it's Column Count property to 2.
Set the Column Width property to 0";1"
Set it's AutoExpand property to Yes.
Set it's LimitToList property to Yes.

Add a Command Button to the form.
Code the button's click event:

DoCmd.OpenQuery "QueryName"
Do.Cmd.Close acForm, Me.Name

Name this form 'ParamForm'.

On the query's [EmployeeID] field criteria line write:
forms!ParamForm!cboFindEmployee

When you wish to run the query, open the form (not the query).
Select the Employee. Click the Command Button.
The query will display and the form will close.
 
Yes, I want to use the query to run a report

fredg said:
Can I create a Parameter query that uses a created combo/list box from the
database in the message that comes up when running the query?

I would like to create a query that prompts me to select an Employee's name
from a long list and then gives me ONLY data associated with the person.

For example, if I run the query, the first thing I should get is a message
box that says "Select the Employee", but instead of just typing the name in
manually (creating possibility for errors), it allows me to just select from
a pre-made list.

I am using Access 2002.

The below is fine if the query is the end result.
However, it's done a bit differently if the query is to be used as the
record source for a report. In which case, post back.

Create an unbound form.
Add a combo box.
Set the Row Source of the combo box to include the
EmployeeID field and the Employee Name.
Name the Combo Box 'cboFindEmployee'.

Set it's Bound column to 1.
Set it's Column Count property to 2.
Set the Column Width property to 0";1"
Set it's AutoExpand property to Yes.
Set it's LimitToList property to Yes.

Add a Command Button to the form.
Code the button's click event:

DoCmd.OpenQuery "QueryName"
Do.Cmd.Close acForm, Me.Name

Name this form 'ParamForm'.

On the query's [EmployeeID] field criteria line write:
forms!ParamForm!cboFindEmployee

When you wish to run the query, open the form (not the query).
Select the Employee. Click the Command Button.
The query will display and the form will close.

Create an unbound form.
Add a combo box.
Set the Row Source of the combo box to include the
EmployeeID field and the Employee Name.
Name the Combo Box 'cboFindEmployee'.

Set it's Bound column to 1.
Set it's Column Count property to 2.
Set the Column Width property to 0";1"
Set it's AutoExpand property to Yes.
Set it's LimitToList property to Yes.

Add a Command Button to the form.
Code the button's click event:

Me.Visible = False

Name this form 'ParamForm'.

On the query's [EmployeeID] field criteria line write:
forms!ParamForm!cboFindEmployee

Code the Report's Open event:
DoCmd.OpenForm "ParamForm", , , , , acDialog

Code the Report's Close event:
DoCmd.Close acForm, "ParamForm"

When you wish to run the report, open the report. It will open the
form. Select the Employee. Click the command button. The report will
display or print. When the report is closed it will close the form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top