ApllyFilter in Subform

  • Thread starter Thread starter Bernardo
  • Start date Start date
B

Bernardo

I am trying to set a button that applies a filter in a
subform. But the form doesn't do it. In a simple filter,
as in the bellow, it just take out all the records. can
some one help me please. Here is the code that I am using
so far:

docmd.applyfilter "forms![MainFormName]![SubFormName]!
[FieldName] = '10'"

the number '10' is just for example. I know that there are
registers with '10'.

Thanks

Bernardo
 
Set the filter property directly

' Set the filter for the sub form
Me.SubFormControlName.Form.Filter = "[FieldName] = '10'"
' Turn the filter on
Me.SubFormControlName.Form.FilterOn = True

Me would have to be replaced with Forms!MainFormName if the button isn't
located on the main form itself.

HTH,

Neil.
 
Back
Top