ACC: Cannot Apply Filter to Subform Using ApplyFilter ActionID: Q112796
|
Moderate: Requires basic macro, coding, and interoperability skills.
You cannot use the ApplyFilter action to apply a filter to a subform. If
you try to do so, the filter is applied to the main form instead. In
Microsoft Access version 1.x, you can achieve some of this functionality
by basing the subform on a parameter query. In the other versions of
Microsoft Access, you can get the same results by changing the subform's
RecordSource property.
The ApplyFilter action dynamically restricts or sorts the records in a
table or the records from a form or report's underlying table or query.
Although you cannot use this action with a subform, you can change the
subform's RecordSource property to achieve the same results.
The following example demonstrates how to change the sort order of a
subform by changing the subform's RecordSource property. It uses the
Categories form and Product List subform in the sample database
Northwind.mdb (or the Categories form and Categories Subform subform in
the sample database NWIND.MDB in 2.0).
CAUTION: Following the steps in this example will modify the sample
database Northwind.mdb. You may want to back up the Northwind.mdb file
or perform these steps on a copy of the Northwind database.
If Me![Product List].Form.RecordSource = "Products" Then
Me![Product List].Form.RecordSource = "UnitPriceSort"
Else
Me![Product List].Form.RecordSource = "Products"
End If
In Microsoft Access 2.0:
If Me![Categories Subform].Form.RecordSource = "Products" Then
Me![Categories Subform].Form.RecordSource = "UnitPriceSort"
Else
Me![Categories Subform].Form.RecordSource = "Products"
End If
For more information about the RecordSource property, search for "RecordSource Property" using the Microsoft Access 97 Help Index.
Additional query words:
Keywords : kbusage kbdta FmsProp
Version : WINDOWS:2.0,7.0,97
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: June 21, 1999