Filtering a subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I currently have a quote form with the quote details subform. The two are
related by quote ID. The quote has a controls selection combo box which i
want to use to filter the subform. The controls is like a category and I wnat
ot the user to only be able to select the correct options for that control in
the subform. I have created a query for the option selection on the subform
and can get it to select one control but only by specifying the id in the
where function of sql.

Is there a way to get it to select the controls id from what is on the quote
form.

Here is the query code.

SELECT Options.OptionID, Options.Option_Name, Options.Price,
Options.Labour_Hours, Options.Engineer_Hours, Options.Controls_ID
FROM Options
WHERE (((Options.Controls_ID)=1));


Thanks for your help
 
WHERE (((Options.Controls_ID)=1));

To get the value of the control on the main form to filter this query, refer
to the control on the main form in the query. In the AfterUpdate event of
the control on the main form, issue a requery command to the control or
subform you're trying to filter.

WHERE (((Options.Controls_ID)=Forms!frmNameOfMainForm!ctlNameOfControl));
 
Thanks that worked but when i scroll through different records with different
controls the names are not shown that i have selected unless i reselect the
control, then the other records do not have the names for the options on the
subform.

Is there anyway to stop this happening or do i just have to put up with it?

Cheers
 
Do you have the Master/Child Link properties set between the main form and
the subform? You can set these to field names. I have also set the Master
Link to a control on the main form, this seems to work properly. Another
option would be to run the requery in the main form's Current event.
 
Excellent! Thank you very much.

Wayne Morgan said:
Do you have the Master/Child Link properties set between the main form and
the subform? You can set these to field names. I have also set the Master
Link to a control on the main form, this seems to work properly. Another
option would be to run the requery in the main form's Current event.
 
Back
Top