Updating fields on a subform from another table

Rob_Burke
Member Posts: 10
I have a subform which has a TableBox showing a list of records.
A short example of this table is:
The No. and Desc. are fields in the table passed into the subform from the main form. The VI No. is a field in the Item table which I want to lookup using the No.
So far, I've tried doing the following:
1. Created a new text C/AL Global named "VINo" and added the control for it
2. Added a function to the subform named GetVINo which does this:
This has sort of worked... now when I load the form my table looks like this:
The problem being that all the VI No. are set to whatever the VI No. of the first record is - I can't figure out how to make it loop through and show the correct VI No. for each row!
Any suggestions?
Thanks a million folks,
Rob
A short example of this table is:
|----------------------------| | No. | Desc. | VI No. | |--------|--------|----------| | 001 | ABC | | | 002 | DEF | | | 003 | GHI | | | 004 | JKL | | |----------------------------|
The No. and Desc. are fields in the table passed into the subform from the main form. The VI No. is a field in the Item table which I want to lookup using the No.
So far, I've tried doing the following:
1. Created a new text C/AL Global named "VINo" and added the control for it
2. Added a function to the subform named GetVINo which does this:
CLEAR(Item); Item.SETRANGE("No.",Rec."No."); IF Item.FIND('-') THEN REPEAT VINo := Item."VINo." UNTIL Item.NEXT = 0;3. Called this function like so:
Form - OnActivateForm() GetVINo; CurrForm.UPDATECONTROLS;
This has sort of worked... now when I load the form my table looks like this:
|----------------------------| | No. | Desc. | VI No. | |--------|--------|----------| | 001 | ABC | V123 | | 002 | DEF | V123 | | 003 | GHI | V123 | | 004 | JKL | V123 | |----------------------------|
The problem being that all the VI No. are set to whatever the VI No. of the first record is - I can't figure out how to make it loop through and show the correct VI No. for each row!
Any suggestions?
Thanks a million folks,
Rob
0
Answers
-
Of course you get just one value, you are using the wrong trigger. You need to use OnAfterGetRecord.
Firstly, why do you use a REPEAT..UNTIL when you get a maximum of 1 record ?
Secondly
- in the OnAfterGetRecord trigger of the form, put the following code :if item.get("No.") then ViNo := Item."ViNo" else ViNo := '' ;
You could also solve this by using a lookup flowfield in the table that is used in the form.0 -
MBerger, I implemented both of your suggestions and it is now working perfectly - thanks a million mate! -Rob0
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