I have a subform which has a TableBox showing a list of records.
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
Answers
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 :
You could also solve this by using a lookup flowfield in the table that is used in the form.