I have three tables,
table one is called fit that has 3 records but might add later.
Table two is called item fit and has for each item the fits that work with it (i.e. for item A it has two records A fit1 and A fit2)
Table three is called design details where it has for every design the fits that work with it and every item has a unique design.
What i want to do is auto populate the item fit table (table 2) when opened from the item card with the fits based on whether the design details have the fit for this design.
This is the code i have written to tackle the task and it is working but I would like to know if there is a better approach since the design details table has a lot of records.
trigger OnAction() var FitRec: Record /Fit/; ItemFitRec: Record /Item Fit/; DesignDetlRec: Record /Design Detail/; begin clear(FitRec); Clear(ItemFitRec); if FitRec.FindSet() then repeat if not ItemFitRec.get(FitRec.Code,Rec.Code) then begin Clear(DesignDetlRec); DesignDetlRec.SetRange(/Design Code/, Rec./Design Code/); DesignDetlRec.SetRange(/Fit Code/, FitRec.Code); if DesignDetlRec.FindSet() then begin ItemFitRec.Init(); ItemFitRec./Item No./ := Rec./No./; ItemFitRec./Fit Code/ := FitRec.Code; ItemFitRec.Insert(true); end; end; until FitRec.Next() = 0; end;