Filter Subform

sarmig
Member Posts: 89
Hi there.
This may seem like a silly and beginner question, but I haven't found the answer anywhere.
I have a form, with a subform in it, and I need to filter a field on the subform (list), based on the value of another field in the main form (card).
For example, my current record in the main form has a field called "type", and its value is 'abc', I want to filter the subform's "type" field with the value 'abc'. Only the lines whose "type" value is 'abc' should appear on the subform.
How do I do it?
This may seem like a silly and beginner question, but I haven't found the answer anywhere.
I have a form, with a subform in it, and I need to filter a field on the subform (list), based on the value of another field in the main form (card).
For example, my current record in the main form has a field called "type", and its value is 'abc', I want to filter the subform's "type" field with the value 'abc'. Only the lines whose "type" value is 'abc' should appear on the subform.
How do I do it?
0
Comments
-
In the properties of the subformbox in the main form you have subformlink.
There you can describe the relation (aka filter) between the main and subform0 -
Can't I do it through code? I need to add another condition in which the filter depends on the value of another field.0
-
Just place a "SetFilter" Function in the Subform which you call from the mainform, which sets the filter.Frank Dickschat
FD Consulting0 -
I wrote this code on the OnAfterGetRecord trigger of the main form. Is there something missing?
(the form_diario_fusao is a form variable of the subform,)recDiarioFusao.RESET; recDiarioFusao.CALCFIELDS(DescMaterial); recDiarioFusao.SETRANGE(DescMaterial, "Cod. Material"); IF recDiarioFusao.FINDFIRST THEN MESSAGE('%1', "Cod. Material"); recDiarioFusao.CALCFIELDS(DescMaterial); MESSAGE('%1', recDiarioFusao.DescMaterial); form_diario_fusao.SETTABLEVIEW(recDiarioFusao);
0 -
I think you need to create a function in Subform and call it from main form by passing the field value
CurrForm.SalesLines.FORM.Filterlinerecords(mainrec.field);0 -
I read that somewhere, and it makes sense, but what would that function do?0
-
Function should filter the Line records based on the passed value..0
-
Found the solution!
"You need to reference directly to the Subform control and not just another instance of the form.
Give the subform control a name in the properties. Let's say MySubForm.
Then you can use:
CurrForm.MySubForm.FORM.SETTABLEVIEW(recDiarioFusao);
Or via function on the Subform as suggested."
http://dynamicsuser.net/forums/p/45628/ ... spx#230706
Thanks for the help0 -
if you modify the value in main form type field from abc to xyz?
is it filtering the subform?0 -
Yes and no.
No, because it's not an editable field.
Yes, because it changes when I change the record (and the value is different).0 -
sarmig wrote:because it's not an editable field.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
- 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