Get a Query to use a combo box selection

  • Thread starter Thread starter Greg Staley
  • Start date Start date
G

Greg Staley

How do I get a query to use a combo box selection as a criteria?

I have a combo box, cboselect, on a form frmSelect and I want to use the
selection from cboSelect in a query, qrySelect, so that I can find the
correct record in the table, tblStudentData.

How on earth do I do that?

THEN..... as if this is not complex enough, I would like to have a subfrom
on the combo box's form open that record for me to see. I have made the
combo box select the record that I want, and I have the subform in place,
but I cannot get them to work. I am pulling my hair out and I don't have
much left.


Can anyone help?

Greg
The always access confused
 
Set the Record Source of the subform to the query you are filtering. To filter the query,
set a reference to the combo box in the criteria:

Forms!frmSelect!cboSelect

This will give you the value in the Bound Column of the combo box. In the AfterUpdate
event of the combo box, requery the subform:

Me!NameOfSubformControl.Form.Requery

The NameOfSubformControl is the name of the control on the main form that holds the
subform. To get this name, open the main form in design mode and open the Properties
window. Click on the subform ONE time and the properties window should show the name of
the subform control. If you click more than once, you'll be in the subform and the
Properties window will show the name of the subform, not the control holding it.
 
Greg Staley said:
How do I get a query to use a combo box selection as a criteria?

I have a combo box, cboselect, on a form frmSelect and I want to use the
selection from cboSelect in a query, qrySelect, so that I can find the
correct record in the table, tblStudentData.

How on earth do I do that?

THEN..... as if this is not complex enough, I would like to have a subfrom
on the combo box's form open that record for me to see. I have made the
combo box select the record that I want, and I have the subform in place,
but I cannot get them to work. I am pulling my hair out and I don't have
much left.

You don't need the query to use the ComboBox (although that is easily set up).
Just set the MasterLink and ChildLink properties of the subform control to use
the ComboBox as the MasterLink and the corresponding field from the subform as
the ChildLink. The records in the sub will automatically filter on the
selection in the Combo.
 
I tried both responses and I cannot get the name of the control for the
first response and for the second it tells me that I cannot link between
unbound forms.

The combo box results are coming from a query, qryDaily, and it is basically
filtering only tardies =date() from a table tblTardies.

How do I link the combo box and the subform so I can use the masterlink and
childlink properties?

Greg
The Always Access confused
 
I tried both responses and I cannot get the name of the control for the first
response and for the second it tells me that I cannot link between unbound
forms.

The combo box results are coming from a query, qryDaily, and it is basically
filtering only tardies =date() from a table tblTardies.

How do I link the combo box and the subform so I can use the masterlink and
childlink properties?

Greg
 
greg said:
I tried both responses and I cannot get the name of the control for the first
response and for the second it tells me that I cannot link between unbound
forms.

Don't use the wizard [...] button. Just type the name of the field in the
ChildLink property and the name of the Combo in the MasterLink property.
 
Back
Top