I've got a form where I want to show a subform with all the related records.
I've got 3 tables: Table1, Table2 and Table1-Table2
In table one I've got field1(pk), field2,field3,...
In table two I've got a similar setup: 2field1(pk),2field2,2field3,...
In table 1-2 I've got the combination of the pk: field1(pk),2field1(pk)
How can I show the related records of the main form's record (based on table1) in the subform (based on table2)
while defining the relation via table 1-2?
Solved: New function in subform with parameter which contains table1.field1,
function(parameter Code[10])
Table1-2.SETRANGE(table1-2.field1,Parameter);
gv_Filter:='=';
IF Table1-2.FINDSET THEN BEGIN
REPEAT
gv_Filter += FORMAT(Table1-2.field2) + '|';
UNTIL Table1-2.NEXT =0;
gv_Filter := DELSTR(gv_Filter,STRLEN(gv_Filter));
SETFILTER(Table2.2field1,gv_Filter);
END ELSE
SETRANGE(Table2.2field1,' ');
CurrForm.UPDATE(FALSE);
In the main form on the aftergetcurrRecord
CurrForm.SubFormID.FORM.function(table1.field1)
Answers
A better solution is to have the subform have table1-2 as sourcetable and in the onaftergetrecord getting the table2.2field1 record.
|To-Increase|