You would need to see if a filter is already applied, grab it, add the additional criteria with AND, then apply that. If you might apply multiple criteria, it's best to enclose the filter in parens. For example, instead of doing:
Field1 = 2
(Field1 = 2)
Then to add another criteria, do:
If Len(Me.Filter) > 0 Then
Me.Filter = Me.Filter & " AND " & "(Field2 = 'A')"
Me.Filter = "(Field2 = 'A')"
John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
On Jan 16, 2016, at 9:45 AM, 'firstname.lastname@example.org' email@example.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
After runing one filter, if a new filter is ran, is possible to filter based on the first filter, instead of on the all records? Thanks.
Kevin-Yes. You need to get to the form inside the subform control like this:Me.SubformControl.Form.Filter = ….. where "SubformControl" is the name of the control that contains the subform.John Viescas, AuthorMicrosoft Access 2010 Inside OutMicrosoft Access 2007 Inside OutMicrosoft Access 2003 Inside OutBuilding Microsoft Access ApplicationsSQL Queries for Mere Mortals(Paris, France)
On Jan 14, 2016, at 9:34 PM, 'firstname.lastname@example.org' email@example.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:Dear All,I learned how to use filter in a form. Is that possible to apply a filter to a subform from main form? Thanks.Private Sub SearchName_AfterUpdate()
On Error GoTo ErrHandle
Me.Filter = "SearchAll Like ""*" & Me.SearchName & "*"""
Me.FilterOn = True
End SubBest Regards,Kevin
Posted by: John Viescas <firstname.lastname@example.org>
|Reply via web post||•||Reply to sender||•||Reply to group||•||Start a New Topic||•||Messages in this topic (5)|