Applying filter on a Subform

deepbluedeepblue Member Posts: 152
Hello!

I need to apply a filter on a field in a subform. The filter is in a text variable and I would to aplly it in the OnOpenForm Trigger in the main form. Can you help me?

Thank you!!!

Answers

  • krikikriki Member, Moderator Posts: 9,118
    Create a function in the subform:
    Function SetSomeFilter(ItxtSomeFilter AS text)
    SETFILTER("Some Field",ItxtSomeFilter);
    

    You have to give your subform a name in the mainform.
    In the "OnOpenForm" of the mainform, you need to put this:
    CurrForm."My Subform".FORM.SetSomeFilter(txtSomeFilter);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • deepbluedeepblue Member Posts: 152
    Thank you Kriki! :D

    But it still a little problem. In the subform, I find a record that should not be there. When I click on it, it disappear !

    Have you a solution please!! :-k

    Thank you!!!
  • krikikriki Member, Moderator Posts: 9,118
    deepblue wrote:
    Thank you Kriki! :D

    But it still a little problem. In the subform, I find a record that should not be there. When I click on it, it disappear !

    Have you a solution please!! :-k

    Thank you!!!
    Change the code in the function of the subform to
    Function SetSomeFilter(ItxtSomeFilter AS text)
    SETFILTER("Some Field",ItxtSomeFilter);
    CurrForm.UPDATE(FALSE);
    
    This refreshes the subform and removes records that are not in the filter.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • deepbluedeepblue Member Posts: 152
    Thank you Kriki!!! =D> \:D/ =D>
Sign In or Register to comment.