Sabtu, 16 Januari 2016

Re: Re: [MS_AccessPros] Is that possible to apply a filter to a subform from main form?

 

John-
I got it. Thanks a lot.
Best Regards,
Kevin


 
Date: 2016-01-16 18:08
Subject: Re: [MS_AccessPros] Is that possible to apply a filter to a subform from main form?
 

Kevin-


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

do:

(Field1 = 2)

Then to add another criteria, do:

If Len(Me.Filter) > 0 Then
    Me.Filter = Me.Filter & " AND " & "(Field2 = 'A')"
Else
    Me.Filter = "(Field2 = 'A')"
End If

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 
(Paris, France)



On Jan 16, 2016, at 9:45 AM, 'zhaoliqingoffice@163.com' zhaoliqingoffice@163.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

John-
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.
Best Regards,
Kevin



 
Date: 2016-01-15 04:42
Subject: Re: [MS_AccessPros] Is that possible to apply a filter to a subform from main form?
 

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, 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 
(Paris, France)



On Jan 14, 2016, at 9:34 PM, 'zhaoliqingoffice@163.com' zhaoliqingoffice@163.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

DoCmd.ShowAllRecords
Me.Filter = "SearchAll Like ""*" & Me.SearchName & "*"""
Me.FilterOn = True
Me.SearchName.SetFocus

ErrExit:
    Exit Sub
    
ErrHandle:
    Resume ErrExit
End Sub

Best Regards,
Kevin





__._,_.___

Posted by: "zhaoliqingoffice@163.com" <zhaoliqingoffice@163.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (6)

.

__,_._,___

Tidak ada komentar:

Poskan Komentar