PDA

View Full Version : Solved: About parameter query



wpanssi
10-17-2008, 10:56 AM
I created a form with access 2007. The form has a dropdown list which shows values of a certain table. The form also has a button and I want that pressing the button will launch a parameter query which uses the value from the dropdown list as the parameter.

I know how to launch the query with the button, but how can I pass the value from the dropdown list to the query, that's the question.

Thanks!

nepotist
10-17-2008, 11:27 AM
in the criteria for the field where you are actually using a parameter.. select the combobox.

in the querydesign view, in the criteria place right click and chose build . there will be three colums in the bottom frame of the pop. In the left most column chose the form that has the criteria(the combo box whose value you want to use as parameter) that is it. It should work fine

CreganTur
10-17-2008, 11:34 AM
It's very simple to do.

First of all, I'm assuming that you're wanting to run a general SELECT query. If you're wanting to run an action query, then we would go about this a completely different way.

On your form, for the code behind your command button, put the following code:
DoCmd.OpenQuery "qryName"
just replace 'qryName' with the name of the query you want to open.

Next, open your query in design view. Click on the criteria row for the field where you want the combobox's value evaluated as the WHERE condition. Enter this:
Forms![FormName]![objectName]
replace 'FormName' with the name of the form, and 'objectName' with your combobox's name.

Everything should work for you now!

I've included an example database if you need it.

wpanssi
10-17-2008, 01:27 PM
Thanks, guys! I'll try with your instructions.

wpanssi
12-07-2008, 01:30 PM
It worked. Markinh this as solved!