Options

Update a field on table from multiple fields from another table using a condition?

TiwazTiwaz Member Posts: 98
Hi guys.
Lets say I need to fill a field "Values" on Table1 to be like this:
"Values" = Text1 + Text2 + Text3 + ... + TextN.
Where Text1...etc are fields in another table, Table2.
Table1 and Table2 have one common field, lets call it "Key" where there can be same values of this field in both tables.
How and where should I put a code for this.
I tried to place this code OnAfterGetRecord trigger of Table1 but it doesn't work

Table2.SETRANGE ("Key","Key");
Values :=' ';
IF Table2.FIND ('-') THEN
REPEAT
Values := Table2.Text1 + ' ' + Table2.Text2 + ' ' + Table2.Text3;
UNTIL
Table2.NEXT = 0;

Best Answer

Answers

  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    It seems table1.Modify Is missing after assigning to field Values?
  • Options
    TiwazTiwaz Member Posts: 98
    If I place that, it gives me this error on run
  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    can you try moving code to OnAfterGetCurrRecord without modify..
    and Currpage.update(FALSE)
  • Options
    TiwazTiwaz Member Posts: 98
    Now it only shows me the first value from the first line. :(
    Those values are Country Code and Country Name from that Table2.
    It needs to read these if they have same "key" as on Table1.
    ex.:
    Table2:
    Key: A1
    C.Code: BE
    Name:Belgium

    Key: A2
    C.Code: GB
    Name:Great Britain

    Key: A1
    C.Code: SI
    Name:Slovenia.

    And if there is a "key": A1 on Table 1,

    I need to show there:BE-Belgium, SI-Slovenia,... from table 2
    But it only shows first one: BE-Belgium
  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    and what if you move to previous trigger without modify and update..
  • Options
    TiwazTiwaz Member Posts: 98
    Same thing happens :(
Sign In or Register to comment.