i am using macro applyfilter on a button click event. in where field i am using "itemid=Forms! NavigationF! Subforms!searchbox
Gasman raises an excellent point in post #4. In the reference string, you have used either one too many elements or one too few elements. My question is, where is
searchbox located?
I'll explain. (The teacher in me just woke up...)
When you use the "bang" or "
!" character you are telling Access (or at least implying) that the item to the LEFT of the bang either IS a collection or it HAS a collection as its default property, and the item to the right of the bang is the NAME of the thing you wanted to find IN that collection. In your case,
Forms!NavigationF looks in
Forms for an object called
NavigationF - and this works because
Forms IS a collection of form objects and in your case, one of them is named
NavigationF. No problem to that point.
You are now on a form object and you repeat the "bang" character (as in
Forms!NavigationF!Subforms). The default behavior on a form is to search the
Controls collection on the form because that collection is the default property of a form. (Just like
.Value is the default property of a text box.) Technically, that reference looks like
Forms("NavigationF")!Controls("Subforms"). However, because Controls was the default property, you can skip it. So
Forms!NavigationF!Subforms works OK if
Subforms was the name of the sub-form control.
It is the next step where there is a problem. If the
searchbox control is on
NavigationF, it would appear in place of where you have
Subforms and that would be the end of the reference string. But you didn't do that, so you must think
searchbox isn't on
NavigationF. The item named
searchbox can't be an item in
Subforms either, because that is a pre-defined control, type sub-form. You cannot define arbitrarily-named objects inside a sub-form control because its components and properties are rigidly defined by Access. In the reference string you used, there is no place for
searchbox to be.
Here's the solution. Sub-forms are just
ordinary forms that are contained in sub-form controls.
Subforms appears to just be the name of a control. If that is ALL it is, then the next thing after
Subforms probably should be
Form - which is the property of a sub-form control that represents the form that was placed in that control. The control is NOT the form. The control CONTAINS the form.
If we use
Form in it proper place, a reference of
Forms!NavigationF!Subforms!Form!searchbox says to look at the form contained in
Subforms and to search ITS default collection (which would again be
Controls) for
searchbox. If that control is in the form contained by
Subforms, then your reference might would work as intended.