Open Form With Filtered Data and prevent clearing the filter

doddwelldoddwell Member Posts: 65
Hello

I have a list form with a menu button. The user selects a record on the "first form" and then clicks the menu button to open a "second form" displaying records filtered to show records associated with the record selected on the "first form".

I know that I can achieve this if I set the PushAction property to "PushAction", the RunObject property to "Form second form", and set the RunFormLink Property. This doesn't give me what I need though because I want "second form" to be filtered and I don't want the user to be able to remove the filter.

I think I can prevent removing the filter on "second form" by using FilterGroup but I don't know how to pass the filter from "first form" to "second form".

Many Thanks for your help.

Comments

  • RCerratoRCerrato Member Posts: 8
    Hi doddwel,

    You should create one function in the second form like SetDataFilter with the parms you want to filter.

    Create some global variables to match your parms and store them there. Then in the onopenform use the fitergroup to filter your required data.

    From your first form, rather than using properties on the button you should use some code

    CLEAR(theform);
    theform.SetDatFilter(YourParms);
    IF theform.RUNMODAL = ACTION::"The action you want to perform" THEN BEGIN
    //some other actions here
    END;
  • ReinhardReinhard Member Posts: 249
    Let me offer up one other solution.

    The "SubFormLink" uses one of the FILTERGROUPS. I forget which one - if I remember correctly it changes in some of the versions.
    Anyways, let's say it uses the normal filtergroup "zero"

    on the second form... onOpenForm:
    filterString := GETFILTERS;
    FILTERGROUP(25);
    SETFILTERS(filterString);
    FILTERGROUP(0);
    

    this has one advantage that no matter where the form is opened from, the filters are "locked"
    For example we use this on the change log, because you shouldn't be able to go and look at HR changes, for example, when opening the change log from an item.

    - Reinhard
  • doddwelldoddwell Member Posts: 65
    Hello RCerrato - Your solution does the trick - Thanks

    Hello Reinhard - I'm trying to test your solution but I'm not sure how to implement it. What code do I need to put onto the first form? You mention in your post about the "SubFormLink" property but my second form is not a subform - is your suggestion still relevant? Thanks
  • ReinhardReinhard Member Posts: 249
    Hi Doddwell,
    Oh, sorry for the confusion.
    You do not need to put any code at all in the first form.

    You mention the user clicks a menu button. Is there code in that button? If yes, maybe post it in the thread. More details + more info = better suggestions.

    Cheers!
    - Reinhard
Sign In or Register to comment.