get sub form record from main form

Debbie140
Member Posts: 52
I have a main form (card form) and a subform(list form) and in the code behind the main form I am trying to find out which record in the subform has been selected.
Say for instance I need to get the primary key of the record selected on the subform when the user clicks a button on the main form and then use this to do some further processing
I have tried using the currform.subformcontrol.FORM to get a handle on the sub form but this does not seem to work. There must be a simple way to to do this but I can't see it. Advice would be appriciated.
Say for instance I need to get the primary key of the record selected on the subform when the user clicks a button on the main form and then use this to do some further processing
I have tried using the currform.subformcontrol.FORM to get a handle on the sub form but this does not seem to work. There must be a simple way to to do this but I can't see it. Advice would be appriciated.
0
Comments
-
Try this:
On the subform, create a function that acccepts as a parameter whatever value you need and returns that value:
EXIT(some_parameter_value);
Call this function on the OnAfterGetCurrRecord trigger of the subform.
Now, on the main form, when you want to know which record is selected just call that function:
some_variable := CurrForm.Subform.FORM.subform_function;
You may also be able to accomplish the same thing with a GETRECORD.0 -
You may also be able to accomplish the same thing with a GETRECORD.
Yes you can
Specify a name for your subform and a variable that matches the records in the subform (ie. SalesLines) then the code will be somethnig like this:CurrForm.mysubform.getrecord(MyRecord)
Then your code would use the information from myrecord.Remember: Keep it simple0 -
Thanks for your answers, both creating function in the subform to return rec.No. and using the CurrForm.SubformControl.FORM.GETRRECORD work.
I am spolied for choice!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