Calling Function in subform

tompynation
Member Posts: 398
Hi, i've added a new subform to the item card.
In this subform i have created the following method:
SetItemCode(ItemCode : Code[20])
gv_ItemCode := ItemCode;
This subform also contains a button with the following push action:
<Control1000000007> - OnPush()
MESSAGE('Item Code: ' + FORMAT(gv_ItemCode));
The gv_ItemCode is a global variable...
Then in Item Card form, in the onaftergetrecord i call the SetItemCode
and pass Rec."No." to it...
If i follow in debugger the gv_ItemCode gets filled up with the Rec."No."
When i then go to the tabpage with my new subform on and press the button, the gv_ItemCode is back empty ](*,)
Why is this?
In this subform i have created the following method:
SetItemCode(ItemCode : Code[20])
gv_ItemCode := ItemCode;
This subform also contains a button with the following push action:
<Control1000000007> - OnPush()
MESSAGE('Item Code: ' + FORMAT(gv_ItemCode));
The gv_ItemCode is a global variable...
Then in Item Card form, in the onaftergetrecord i call the SetItemCode
and pass Rec."No." to it...
If i follow in debugger the gv_ItemCode gets filled up with the Rec."No."
When i then go to the tabpage with my new subform on and press the button, the gv_ItemCode is back empty ](*,)
Why is this?
0
Answers
-
i call the SetItemCode in the OnAfterGetRecord form the Item card like this:
gv_EenhedenSubForm.SetItemCode("No.");
gv_EenhedenSubForm is a global variable of type Form0 -
Do you call the function from your Subform in your Form - OnAfterGetRecord() Trigger?Do you make it right, it works too!0
-
MainForm:
Form - OnAfterGetRecord()
CurrForm.SubForm.FORM.SetItemNo("No.");
SubForm:
SetItemNo(LocItemNo : Code[20])
GlobItemNo := LocItemNo;
Button on Subform
<Control1119402007> - OnPush()
MESSAGE(GlobItemNo);Do you make it right, it works too!0 -
If I am not mistaken, your problem is retrieving the Item number from the sub form..? If this is the case, then change the property name of your subform and call the GETRECORD function in the subform in your button. Something like this code
CurrForm.YourSubFormName.GETRECORD(RetrieveRecord); MESSAGE("RetrieveRecord.No.");
for more details for the GETRECORD function. Please read the help.Navision noob....0 -
No thats not what i mean...
I want to have the Item rec inside my subform
I dont want to have the record from my subform inside the Item Card Form0 -
Pass the record by reference. To do this just mark the Var field in your function parameters.Navision noob....0
-
CurrForm.SubForm.FORM.SetItemNo("No.");
This was what i needed... i was unable to call the function of my named subform cause i allways tried like CurrForm.SubForm.SetItemNo("No.")
which was not valid off course
I didnt know you had to add .FORM between it
Anyway, works fine now. Thanks for the help O:)0 -
Please.
Please write [solved] infront of you subject (first post)Do you make it right, it works too!0 -
hi,this is my code ,it is successful,i think it can help you,
my subform name is :salelines,and I add a function example
example()
message('it is ok');
main form I add button I call it
currform.saleline.form.example;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