Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop Down Queries?

Status
Not open for further replies.

SShefer

Technical User
Aug 7, 2001
20
US
I have a very quick question:

When I run a query from a switchboard in order to narrow down my customer list I have to type exactly what I want. Now is there a way fo Access to take the info from those fields and create a drop down right in the query?

Thanks
 
You could create a combobox with the required list
the in the criteria of that query have it point to the ComboBox for example:

Criteria = Forms!Form_Name!ComboBox.Colunm(1)

Colunm(1) is under the assumption that you have the Key Field hidden or in other words you have to fields in your ComboBox. If not then select Colunm(0)

then on the AfterUpdate_Event of the ComboBox Run the Query.

HTH
 
SShefer,

Was your question about defining the criteria or having a dropdown list of values to select as criteria?

ToeShot's guidance will define the criteria for the query.

If you want a dropdown on your switchboard so you don't have to type, add a combo box with the wizard.

In answer to the questions the wizard asks:

1.) You want the combo box to look up the values in a table or query. Next >
2.) Select the View Queries radio button and select your query. Next >
3.) Select the field you want displayed. Next >
4.) Adjust the width of the column. Next >
5.) You want to "Remember the value for later use.' Next >
6.) Type in the label caption. Finish >

In the Properties pane, Data tab, look at the Combo Box's Row Source. EG:
Code:
 SELECT DISTINCTROW[qryCustomerAddress].[PostalCode] FROM [qryCustomerAddress]
To eliminate the repeated values in the list, change the word DISTINCTROW to DISTINCT.

Then, do what ToeShot said.

HTH

John

 
Does anyone know if you can accomplish this in a regular parameter query? (ie not based from a switchboard)

I have some lengthy names of locations in a table (that are to be used as criteria for a query) and I know that people are bound to make errors in entering the parameter if they are left to their own devices. I can't get anything other than a blank space there and I have also tried creating my own form (with the drop down box on it) and attaching that to the criteria in the query and I can't seem to make that work, either. If I put this in the query:
Criteria = Forms!Form_Name!ComboBox.Colunm(1)
I get a parameter box with a blank and Forms!Form_Name!ComboBox.Colunm(1) as the caption.

Can anyone help?

Regards,
Rayna
 
Rayna
It sounds Like your Form is not open or you have nothing selected in your ComboBox.

Let me Know and i will try and help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top