Copy data from one table to another with filters

HexHex Member Posts: 6
edited 2005-05-07 in Navision Attain
Hi.

Currently I need to maintain some info in one table, and be able to copy this data to another table.

The table structure is like this:

Table 1 (blank)
____________

Table 2 (Main Item)
________________
1
2
3

Table 3 (Item Value)
_________________
1 a
1 b
1 c


Table 1 is the table I need to populate.
Table 2 is the table that holds the main 'item', with a 'subtable' (Table 3) that holds the 'itemvalues'.

When I look up in Table 2 from Table 1, I would like to be able to select e.g. '1', and the values for 1 from Table 3 (a,b,c), should be copied to Table 1, so Table 1 now looks like this:

Table 1
_______
a
b
c

One of the fields in Table 1 is related to 27 Item. So therefore, the values from Table 3, should only be copied to the Item, I have currently looked up.

Thx in advance...
Who the hell is General Failure, and why is he reading my disk?

Comments

  • pdjpdj Member Posts: 643
    So table 2 contains template headers, and table 3 template lines/values for table 1. Well, something like this I guess: (Not tested, validate or anything)
    OnLoopup():
    IF NOT FORM.RUNMODAL(0,Tab2) = Action::LookupOK THEN
      EXIT;
    Tab1.DELETEALL;
    Tab3.SETRANGE("First Field",Tab2."First Field");
    IF Tab3.FIND('-') THEN
      REPEAT
        Tab1.TRANSFERFIELD(Tab3,TRUE); // Req. the tables are designed for it, otherwise field by field
        Tab1.INSERT;
      UNTIL Tab3.NEXT = 0;
    

    PS: I most likely don't understand what you are trying to do - please be a bit more specific :-)
    Regards
    Peter
  • HexHex Member Posts: 6
    To be more specific, it is the Variants table that, in this case, is Table 1.

    The Template table is, as you say, Table 2. The template lines are in Table 3.

    I have made a form using Table 2, with a subform using Table 3.

    I have set a filter, so that when select f.x. Code 1 in the form showing Table 2, the values for Code 1 from Table 3 is then shown in the subform.

    What I would like to do now, is to Click OK in the form, so that the values from Table 3 for that code, is transferred to the Variants table for the specific Item record that I am currently editing.
    Who the hell is General Failure, and why is he reading my disk?
Sign In or Register to comment.