Reuse subform with different table relation

tompynation
Member Posts: 398
Imagine that you have a custom table containing the Field Item.
Inside this table the table relation for this field consist of:
Item.No. WHERE (Item Category Code=CONST(V))
Now i created a subform for this table...
The problem is that i would like to reuse this form now.
So on my main form i would have this subform twice.
But the table relation should switch in the second subform to:
Item.No. WHERE (Item Category Code=CONST(G))
Is it possible?
Inside this table the table relation for this field consist of:
Item.No. WHERE (Item Category Code=CONST(V))
Now i created a subform for this table...
The problem is that i would like to reuse this form now.
So on my main form i would have this subform twice.
But the table relation should switch in the second subform to:
Item.No. WHERE (Item Category Code=CONST(G))
Is it possible?
0
Answers
-
i found it, i had to declare the onLookup trigger inside the subform itself.
Not in the table0 -
Hi,
Insert custom lookup code in both of subform. Diffrent filter on each lookup solve your problem.
Something likeLookupRec.Setfilter(type,type::"1"); IF LookupRec.GET("Field No.") THEN; IF FORM.RUNMODAL(0,LookupRec)=ACTION::LookupOK THEN VALIDATE("Field No.",LookUpRec."No.");
0 -
You can also set the tablerelationship to just the Item number, and include the Item Category Code filter in the subform link. That way, no code at all and you can use the same subform with different filters.0
-
Also remember that
Item.No. WHERE (Item Category Code=CONST(V))
is hardcoding - you do not want to restrict the subform based on a CONST value that could be different for different companies in teh same database!
Best to have that field (V, G, whatever) be in a setup table somewhere, and use FILTERGROUPs along with the setup field to have the correct filtering in the subform.
-awarn0
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
- 320 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