Set subformview programmatically

tompynationtompynation Member Posts: 398
Hi,

How could i set a subformview in the OnAfterValidate of a recordfield from the mainform?

The subform should also only get visible, when this RecordField gets validated...

Answers

  • girish.joshigirish.joshi Member Posts: 407
    if you specify a filter for filter group 3 you should be able to change this at runtime.
  • tompynationtompynation Member Posts: 398
    i dont know that... :roll:

    How should i set the filtergroup for the subform?
  • tompynationtompynation Member Posts: 398
    i found on the forum this to set the filter group:

    SETFILTER("Customer Name",'ABC*');
    FILTERGROUP(6);
    SETFILTER("Customer Name",'*XYZ*');
    FILTERGROUP(0);

    Do i have to call this code inside the subform ?

    Or just execute this in the main form?
  • kinekine Member Posts: 12,562
    Give name to the subform control, and than check the
    CurrForm.<MySubformName>.FORM.SETTABLEVIEW()
    

    function for how to set the filters on the subform...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • tompynationtompynation Member Posts: 398
    i cannot use the settableview cause i can only pass a record to this function...

    In my subform there is a tablebox which shows all record from the table Recept.

    This table contains the Field ReceptID.
    Now i like to filter the subform to show only the records who correspond to a given ReceptID

    How to do that
  • kinekine Member Posts: 12,562
    The function is passing filters not record... may be I do not understand correctly, but you just needs one variable of type record for same table as the subform is based on, set the requested filters (e.g. on the Receipt ID field) and pass these filters by passing this variable as parmeter of the function described above...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • tompynationtompynation Member Posts: 398
    aha, now i see what you mean.

    Its sort of working now using this code:


    lv_Length := STRLEN(Productcode);

    IF lv_Length > 0 THEN BEGIN
    lv_ReceptID := GetReceptID(Productcode);
    lv_ReceptItem.SETFILTER(lv_ReceptItem.ReceptID,'%1',lv_ReceptID);
    CurrForm.POProductFormuleSub.FORM.SETTABLEVIEW(lv_ReceptItem);
    CurrForm.POProductFormuleSub.FORM.VISIBLE := TRUE;
    END
    ELSE IF lv_Length = 0 THEN BEGIN
    CurrForm.POProductFormuleSub.FORM.VISIBLE := FALSE;
    END;

    The only problem is the update of the subform now...
  • kinekine Member Posts: 12,562
    Update of the subform was solved many times on this forum... just add something like UpdateForm function on the subform calling the CurrForm.UPDATE(False); and call this function from the main form...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • tompynationtompynation Member Posts: 398
    update is working now, i forget to pass the FALSE attribute to the UPDATECONTROLS... ](*,)
Sign In or Register to comment.