ApllyFilter in Subform

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
 
N

Neil

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top