ApplyFilter event on a subform

  • Thread starter Thread starter Rob Parker
  • Start date Start date
R

Rob Parker

I have a form with two subforms, and I'm trying to apply the same
filtering - set in one subform - to both. I'm using the following code in
Subform1:

Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
MsgBox "filter applied: FilterType = " & ApplyType
Me.Parent.Form.Controls("Subform2").Form.Filter = Me.Filter
Me.Parent.Form.Controls("Subform2").Form.FilterOn = Me.FilterOn
End Sub

This works fine when I apply a filter to the first subform. Unfortunately,
it doesn't work when I remove the filter from the first subform; the
ApplyFilter event is not triggered in that case. If I open Subform1 as a
standalone form, and apply or remove a filter, the ApplyFilter event is
triggered in both cases (with ApplyType = 1 when I set a filter, and
ApplyType = 0 when I remove the filter).

Why doesn't this work when Subform1 is a subform of a parent form, and
what's the workaround to get it to work (ie. to remove the filter from
Subform2 when it is removed from Subform1)?

TIA,

Rob
 
And answering my own post after some more testing:

When the filter is removed from Subform1 when it is "open" in a parent form,
the ApplyFilter event of Subform1 is not triggered, but instead the
ApplyFilter event of the parent form is triggered. I can use this to remove
the filer from Subform2.

Seems weird, but I'm not completely surprised ;-)

Rob
 
Back
Top