Subform with a many to many relation.
Sog
Member Posts: 1,023
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])
In the main form on the aftergetcurrRecord
CurrForm.SubFormID.FORM.function(table1.field1)
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)
0
Answers
-
This is only for showing the records.
A better solution is to have the subform have table1-2 as sourcetable and in the onaftergetrecord getting the table2.2field1 record.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions