Apply a filter to a subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I ma using this code to build a filter and am not sure how to apply it to a
datasheet view subform. Can anyone help me with the syntax for that?

'draw filter criteria from open form
strCourseName = BuildCriteria("screenID", dbText, "Me!cboFilter.Column(2)")
'my failed syntax to apply filter to a second open but hidden form
Forms!frmFirstFilter.Form!tblCollection.Filter = strCourseName
 
Try:
With Me.tblCollection.Form
.Filter = strCourseName
.FilterOn = True
End With

If that doesn't work:
1. Open the main form in design view.
2. Right-click the edge of the subform control, and choose Properties.
3. On the Other tab of the Properties box, what is the Name of the subform
control?

The Name of the control can be different from its SourceObject (the name of
the form that is loaded into the subform control).

BTW, you probably don't want to filter both the main form and the subform at
the same time. If you do that, Access is likely to get very confused when
you remove one of the filters. Details in:
Incorrect filtering of forms and reports
at:
http://members.iinet.net.au/~allenbrowne/bug-02.html
 
Back
Top