Easiest way to enable controls to filter subform content

  • Thread starter Thread starter Spidey3721
  • Start date Start date
S

Spidey3721

I am getting familiar with writing the code neccessary to use a from control
to filter subform data - Wondring if there is an easier way, such as adding
some WHERE criteria to the record source of the subform itself that points
to some of the main form controls
 
Open the main form in design mode and open the properties sheet. Click on
the subform ONE time to have the properties sheet show the properties of the
subform control on the main form, not the properties of the subform. On the
Data tab fill in the Link Child Field and Link Master Field options.

For the Link Child Field, type in the name of the field on the subform that
you want to filter.

Example:
[Field1]

For the Link Master Field, type in the name of the control on the main form
that will provide the filter value.

Example:
cboMyComboBox

Remember, the value of the combo box comes from its Bound Column, which may
not be a visible column.
 
The only problem that I have with that, is that if I change the combobox in
order to change the filter of the subform, then aren't I modifying the
actaul value of the field for the active main form record that the combobox
is bound to? I want to really have an unbound control that is ONLY used for
filtering the subform, but I can't seem to do that by using master/child
links because I can only seem to choose Main form Record Source fields...






Wayne Morgan said:
Open the main form in design mode and open the properties sheet. Click on
the subform ONE time to have the properties sheet show the properties of the
subform control on the main form, not the properties of the subform. On the
Data tab fill in the Link Child Field and Link Master Field options.

For the Link Child Field, type in the name of the field on the subform that
you want to filter.

Example:
[Field1]

For the Link Master Field, type in the name of the control on the main form
that will provide the filter value.

Example:
cboMyComboBox

Remember, the value of the combo box comes from its Bound Column, which may
not be a visible column.

--
Wayne Morgan
MS Access MVP


Spidey3721 said:
I am getting familiar with writing the code neccessary to use a from control
to filter subform data - Wondring if there is an easier way, such as adding
some WHERE criteria to the record source of the subform itself that points
to some of the main form controls
 
No, in the Master Link you put the name of the control, not the name of the
field. This will allow it to work with an unbound control. The Row Source of
the combo box will still fill the drop down with the values even though the
combo box is unbound. When you select one of those values, the bound field
of the combo box will be used as the filter value for the subform.
 
Back
Top