Applying a where clause to a subform's filter?

  • Thread starter Thread starter allie357
  • Start date Start date
A

allie357

I am getting a user defined error here.
I am trying to apply the Where clause to the filter in a query within
the subform Forms.frmSearchCriteriaSub that is on the
frmSearchCriteriaMain.

'Finally, apply the string as the form's Filter.
Forms.frmSearchCriteriaMain.frmSearchCriteriaSub.Form.qrySearchCriteriaSub
= strWhere
Forms.frmSearchCriteriaMain.frmSearchCriteriaSub.Form.qrySearchCriteriaSub.Filter.FilterOn
= True

can anyone help?
thanks in advance.
 
Not positive, but it looks like a syntax problem. You don't need to use the
name of the subform.

Forms!frmSearchCriteriaMain!frmSearchCriteriaSub.Form.Filter = strWhere
Forms!frmSearchCriteriaMain!frmSearchCriteriaSub.Form.Filter.FilterOn = True
 
I need to filter the qry which is displayed on a subform. The criteria
comes from the combo boxes on the main form. When I put Me.Filter
nothing happens since I know it is applying the filter to the main
form.
 
Hi. I'm not sure whether it's just the format of your post, but your last
code line looks all jumbled. You seem to have both the filter and filteron
methods in the same line. I would expect something like

Forms!frmSearchCriteriaMain!frmSearchCriteriaSub.Filter =
"[controlToFilterOn] = '" & strFilterCritera & "'"
Forms!frmSearchCriteriaMain!frmSearchCriteriaSub.FilterOn = True

Note that in the search string there are apostrophes after the equals before
the quote, the between the pair of quotes at the end.
 
I need to filter the qry which is displayed on a subform. The criteria
comes from the combo boxes on the main form. When I put Me.Filter
nothing happens since I know it is applying the filter to the main
form.

Reread Klatuu's post. He's right.

You're trying to set the filter property of the Subform Control; it
doesn't HAVE a filter property. The Form object *within* the subform
control does. You need the .Form. in the object name.

John W. Vinson[MVP]
 
When I input the code in Klatuu's post I get error 424 and when I put
in the code below I get error 438 Object not supported. I must be
misinterpreting what you are telling me?
It just doesn't seem to want to work...

Forms!frmSearchCriteriaMain!frmSearchCriteriaSub.Form.Filter = strWhere
Forms!frmSearchCriteriaMain!Filter.FilterOn = True
Hi. I'm not sure whether it's just the format of your post, but your last
code line looks all jumbled. You seem to have both the filter and filteron
methods in the same line. I would expect something like

Forms!frmSearchCriteriaMain!frmSearchCriteriaSub.Filter =
"[controlToFilterOn] = '" & strFilterCritera & "'"
Forms!frmSearchCriteriaMain!frmSearchCriteriaSub.FilterOn = True

Note that in the search string there are apostrophes after the equals before
the quote, the between the pair of quotes at the end.

allie357 said:
I am getting a user defined error here.
I am trying to apply the Where clause to the filter in a query within
the subform Forms.frmSearchCriteriaSub that is on the
frmSearchCriteriaMain.

'Finally, apply the string as the form's Filter.
Forms.frmSearchCriteriaMain.frmSearchCriteriaSub.Form.qrySearchCriteriaSub
= strWhere
Forms.frmSearchCriteriaMain.frmSearchCriteriaSub.Form.qrySearchCriteriaSub.Filter.FilterOn
= True

can anyone help?
thanks in advance.
 
Forms!frmSearchCriteriaMain!frmSearchCriteriaSub.Form.Filter = strWhere
Forms!frmSearchCriteriaMain!Filter.FilterOn = True

The second line needs to reference the Form property of the subform
object:

Forms!frmSearchCriteriaMain!frmSearchCriteriaSub.Form.FilterOn = True


John W. Vinson[MVP]
 
Back
Top