How do I make query parameters with a drop down list?

R

rangersims

I want a parameter query that prompts the user with a drop-down list to enter
the data, rather than the user typing a string. This way, I can limit which
data the user can search for. Is this possible?

If not, how can I prevent Access from displaying a blank record when the
user enters a string in the query parameter dialog box that has no matching
records? I want to prevent users from creating a record when no record
exists with the criteria they searched for.
 
F

fredg

I want a parameter query that prompts the user with a drop-down list to enter
the data, rather than the user typing a string. This way, I can limit which
data the user can search for. Is this possible?

If not, how can I prevent Access from displaying a blank record when the
user enters a string in the query parameter dialog box that has no matching
records? I want to prevent users from creating a record when no record
exists with the criteria they searched for.

You'll need to use a form to do this.

Let's assume you wish to return records for a particular company.
Make a new unbound form.
Add a combo box that will show the CompanyID field, as well as the
CompanyName field.

Make sure the Combo Box Bound Column is the
same DataType as the CompanyID field in the table.
Set the Combo Box ColumnWidths property to
0";1"
Name this Combo Box 'cboFindCompany'.

Add a command button.
Code the button's Click event:

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

Name this form "ParamForm"

Code the Query CompanyID field criteria line
forms!ParamForm!cboFindCompany

When you are ready to view the query, open the form.
Find the CompanyID in the combo box.
Click the command button.

The query will display just those records selected.
The Form will close.
 

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

Top