parameter query

  • Thread starter Thread starter Fred
  • Start date Start date
F

Fred

Is it possible to setup a parameter query where the parameter is a combo
box?
ie. A query for sales where the parameter is a dropdown list from another
table.

Thanks,
Fred
 
Fred said:
Is it possible to setup a parameter query where the parameter is a combo
box?
ie. A query for sales where the parameter is a dropdown list from another
table.

Sure in a query, it would look like this:

PARAMETERS [Forms]![MyForm]![cboMyCombo] Text ( 255 );
SELECT MyTable.ID, MyTable.AnotherField
FROM MyTable
WHERE (((MyTable.ID)=[Forms]![MyForm]![cboMyCombo]));
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Not directly.

You can set up a form that invokes the query. The form can have a combo box
on it, and the parameter on the query can reference the contents of the
combo box.

If the form is called frmForm and the combo box is called cmbCombo, then the
criteria in the appropriate column of the query would read:

forms!frmForm!cmbCombo

The column of the combobox that has the data you want to use as the criteria
must be the bound column.
 
Thanks for the help

JP said:
Not directly.

You can set up a form that invokes the query. The form can have a combo box
on it, and the parameter on the query can reference the contents of the
combo box.

If the form is called frmForm and the combo box is called cmbCombo, then the
criteria in the appropriate column of the query would read:

forms!frmForm!cmbCombo

The column of the combobox that has the data you want to use as the criteria
must be the bound column.
 
Is it possible to setup a parameter query where the parameter is a combo
box?
ie. A query for sales where the parameter is a dropdown list from another
table.

What you need to do is create a small unbound Form, frmCrit let's call
it, with the combo box (and controls for any other desired criteria).
Let's say you have a combo box cboCustomer.

Your Query would use

=[Forms]![frmCrit]![cboCustomer]

as the criterion. Form frmCrit must be open at the time the query is
run; it's convenient to base a Form (for onscreen display) or a Report
(for printing) on the query, and put a command button on frmCrit to
open said form or report. There's no need to open the query datasheet
at all.

John W. Vinson[MVP]
 
Back
Top