Updating a (different) table form a list-form

jensthomsenjensthomsen Member Posts: 173
Hi
I have a form Form1 (List) with sourcetable Table1. When I move up/down the records in Table1 on Form1, I want to be able to Insert/delete/modify records in anothe table Table2. Shouldn't that be possible? I have tried putting my "update-code" on both the OnafterGetRecord and OnAfterGetCurrRecord on Form1, but getting the Error Transaction not started (error in Danish: "Du kan ikke ændre i databasen, før der er startet en ny transaktion").

Comments

  • garakgarak Member Posts: 3,263
    why do you need a update in a second table if you browse trough table 1 :?:
    Whats the reason :?:
    Do you make it right, it works too!
  • jensthomsenjensthomsen Member Posts: 173
    garak wrote:
    why do you need a update in a second table if you browse trough table 1 :?:
    Whats the reason :?:

    He - he :)
    I will build a filter on records in table1, by making some sort of entries in table2, and then use a calcfield on table 1 to see if there are any entries in table2. The reason for this is, that I need a complex filter and can not use a temporary record. But I have to update the entries in Table2....
  • XypherXypher Member Posts: 297
    If I understand what you're trying to do correctly, here is a small example on how you can "interpret" more than one table on a single form. Although there is no code to modify any data, I'm sure you get the point.

    (If you're unsure of where you can place your code to modify the 'non-source table to the form' try experimenting under the OnAfterInput or OnValidate of the "mock-fields" for the external table.)
    [Be sure to make use of CurrForm.UPDATE(FALSE), or issue some kind of logic in 'Form - OnModifyRecord() : Boolean' as to prevent any changes to the source table]

    I hope this will point you in the right direction,
    OBJECT Table 60021 Temp Data
    {
      OBJECT-PROPERTIES
      {
        Date=08/01/08;
        Time=11:08:38 AM;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
      }
      FIELDS
      {
        { 1   ;   ;ID                  ;Code10         }
        { 1001;   ;Order1              ;Code20         }
        { 1002;   ;Order2              ;Code20         }
        { 1003;   ;Order3              ;Code20         }
        { 1004;   ;Order4              ;Code20         }
        { 1005;   ;Order5              ;Code20         }
        { 1006;   ;Order6              ;Code20         }
      }
      KEYS
      {
        {    ;ID                                      ;Clustered=Yes }
        {    ;Order1,Order2,Order3,Order4,Order5,Order6 }
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    
    OBJECT Table 60020 Test Table
    {
      OBJECT-PROPERTIES
      {
        Date=08/07/08;
        Time=10:45:34 AM;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
      }
      FIELDS
      {
        { 1   ;   ;ID                  ;Code10         }
        { 2   ;   ;ID Name             ;Text30         }
        { 3   ;   ;Order Name          ;Text30         }
      }
      KEYS
      {
        {    ;ID                                       }
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    
    OBJECT Form 60020 Test Form
    {
      OBJECT-PROPERTIES
      {
        Date=08/07/08;
        Time=10:45:56 AM;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=12980;
        Height=12100;
        Maximizable=No;
        Sizeable=No;
        SaveControlInfo=No;
        SavePosAndSize=No;
        SaveColumnWidths=No;
        InsertAllowed=No;
        DeleteAllowed=No;
        ModifyAllowed=No;
        TableBoxID=1000000000;
        SourceTable=Table60021;
        SourceTablePlacement=First;
        SaveTableView=No;
      }
      CONTROLS
      {
        { 1000000000;TableBox;0   ;0    ;12980;5500  }
        { 1000000013;TextBox;11947;2420 ;1700 ;440  ;Editable=No;
                                                     ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr=ID }
        { 1000000014;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000013;
                                                     InColumnHeading=Yes }
        { 1000000001;TextBox;1747 ;2420 ;1700 ;440  ;Editable=No;
                                                     ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr=Order1 }
        { 1000000002;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000001;
                                                     InColumnHeading=Yes }
        { 1000000003;TextBox;3447 ;2420 ;1700 ;440  ;Editable=No;
                                                     ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr=Order2 }
        { 1000000004;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000003;
                                                     InColumnHeading=Yes }
        { 1000000005;TextBox;5147 ;2420 ;1700 ;440  ;Editable=No;
                                                     ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr=Order3 }
        { 1000000006;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000005;
                                                     InColumnHeading=Yes }
        { 1000000007;TextBox;6847 ;2420 ;1700 ;440  ;Editable=No;
                                                     ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr=Order4 }
        { 1000000008;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000007;
                                                     InColumnHeading=Yes }
        { 1000000009;TextBox;8547 ;2420 ;1700 ;440  ;Editable=No;
                                                     ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr=Order5 }
        { 1000000010;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000009;
                                                     InColumnHeading=Yes }
        { 1000000011;TextBox;10247;2420 ;1700 ;440  ;Editable=No;
                                                     ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr=Order6 }
        { 1000000012;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000011;
                                                     InColumnHeading=Yes }
        { 1000000015;TableBox;0   ;5610 ;12980;5500  }
        { 1000000021;TextBox;0    ;8140 ;4180 ;440  ;Editable=No;
                                                     ParentControl=1000000015;
                                                     InColumn=Yes;
                                                     SourceExpr=ID;
                                                     OnFormat=BEGIN
                                                                IF TestTable.GET(ID) THEN
                                                                  Text := TestTable.ID
                                                                ELSE
                                                                  CLEAR(Text);
                                                              END;
                                                               }
        { 1000000022;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000021;
                                                     InColumnHeading=Yes }
        { 1000000017;TextBox;4154 ;8250 ;1700 ;440  ;ParentControl=1000000015;
                                                     InColumn=Yes;
                                                     SourceExpr=Order1;
                                                     OnFormat=BEGIN
                                                                IF TestTable.GET(ID) THEN
                                                                  Text := TestTable."ID Name"
                                                                ELSE
                                                                  CLEAR(Text);
                                                              END;
                                                               }
        { 1000000018;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000017;
                                                     InColumnHeading=Yes }
        { 1000000019;TextBox;7197 ;8910 ;1700 ;440  ;ParentControl=1000000015;
                                                     InColumn=Yes;
                                                     SourceExpr=Order2;
                                                     OnFormat=BEGIN
                                                                IF TestTable.GET(ID) THEN
                                                                  Text := TestTable."Order Name"
                                                                ELSE
                                                                  CLEAR(Text);
                                                              END;
                                                               }
        { 1000000020;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000019;
                                                     InColumnHeading=Yes }
        { 1000000016;CommandButton;10560;11330;2200;550;
                                                     PushAction=Close }
      }
      CODE
      {
        VAR
          TestTable@1000000000 : Record 60020;
    
        BEGIN
        END.
      }
    }
    
Sign In or Register to comment.