Lookup

siyaksiyak Member Posts: 66
Hi there pips

I've created two table(T1 and T2) and i want to link them.one table have the two fields(No.which is a Code10 and name filed Option) on T2 i have (customer No. (code10),No.(Code10),Name(option) and other fields) i have 2 forms for both of them(F1 and F2).The table relation on T2
T2."No." WHERE (Name=FIELD(Name)).
On F2 when i'm on the "No." i need to lookup T1 and its not working.

I have the following code on Onvalidate and OnLookup of T2
IF "Customer No." = COPYSTR("Shearing Shed No.",1,6) THEN
VALIDATE("Main Shed",TRUE)
ELSE
"Main Shed" := FALSE;
Which validates other fields

Comments

  • krikikriki Member, Moderator Posts: 9,110
    Remove your code from the OnLookup-trigger.
    The fact that there is some code, makes it that the standard onlookup is NOT triggered. (You may NOT even put some documented line on the trigger!).
    The Validate-trigger will be run when you leave the field after selecting a value with the lookup.

    PS don't forget the LookupFormID-property on the table in which you want to select a value.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • siyaksiyak Member Posts: 66
    i've trid that,but still doesn't do the lookup
  • siyaksiyak Member Posts: 66
    Pips i've tried to remove the code from the Onlookup and onValidate and when i'm on the form it doesn't do the lookup ](*,) please help
  • krikikriki Member, Moderator Posts: 9,110
    siyak wrote:
    Pips i've tried to remove the code from the Onlookup and onValidate and when i'm on the form it doesn't do the lookup ](*,) please help
    PS don't forget the LookupFormID-property on the table in which you want to select a value.
    Did you do this?
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • siyaksiyak Member Posts: 66
    Yes i did it,but it removes the lookup button ](*,)
  • siyaksiyak Member Posts: 66
    Please help i've tried everything i know about lookup.I tried to make that field a flowfield and do the calc formular for lookup,but i does'nt work. :oops:
  • krzychub83krzychub83 Member Posts: 120
    :-k
    I've created two table(T1 and T2) and i want to link them.one table have the two fields(No.which is a Code10 and name filed Option) on T2 i have (customer No. (code10),No.(Code10),Name(option) and other fields) i have 2 forms for both of them(F1 and F2).The table relation on T2
    T2."No." WHERE (Name=FIELD(Name)).
    TableRelation: T1."No."
    On F2 when i'm on the "No." i need to lookup T1 and its not working.

    I have the following code on Onvalidate and OnLookup of T2
    IF "Customer No." = COPYSTR("Shearing Shed No.",1,6) THEN
    VALIDATE("Main Shed",TRUE)
    ELSE
    "Main Shed" := FALSE;
    Which validates other fields
    Put code only in onValidate() trigger.

    OK ... This will be quicker:
    (2 basics examples of using LookUP)
    OBJECT Table 59998 TableExample1
    {
      OBJECT-PROPERTIES
      {
        Date=08-06-04;
        Time=17:56:55;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        LookupFormID=Form59998;
      }
      FIELDS
      {
        { 1   ;   ;No.                 ;Code20         }
        { 2   ;   ;No Table2           ;Code20        ;TableRelation=TableExample2.No.;
                                                       OnValidate=BEGIN
                                                                    MESSAGE('MESSAGE FROM TABLE TRIGGER ONVALIDATE!');
                                                                  END;
                                                                   }
        { 3   ;   ;No Table2 2         ;Code20         }
        { 4   ;   ;Description From Table2;Text30      }
      }
      KEYS
      {
        {    ;No.                                      }
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    
    OBJECT Table 59999 TableExample2
    {
      OBJECT-PROPERTIES
      {
        Date=08-06-04;
        Time=17:37:14;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        LookupFormID=Form59999;
      }
      FIELDS
      {
        { 1   ;   ;No.                 ;Code20         }
        { 2   ;   ;Description         ;Text30         }
      }
      KEYS
      {
        {    ;No.                                      }
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    
    OBJECT Form 59998 FormExample1
    {
      OBJECT-PROPERTIES
      {
        Date=08-06-04;
        Time=18:02:52;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=11150;
        Height=6710;
        TableBoxID=1000000000;
        SourceTable=Table59998;
      }
      CONTROLS
      {
        { 1000000000;TableBox;220 ;220  ;10710;5500 ;HorzGlue=Both;
                                                     VertGlue=Both }
        { 1000000001;TextBox;0    ;0    ;1700 ;0    ;ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr="No." }
        { 1000000002;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000001;
                                                     InColumnHeading=Yes }
        { 1000000003;TextBox;0    ;0    ;1700 ;0    ;ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr="No Table2" }
        { 1000000004;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000003;
                                                     InColumnHeading=Yes }
        { 1000000005;TextBox;0    ;0    ;1700 ;0    ;ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     Lookup=Yes;
                                                     SourceExpr="No Table2 2";
                                                     OnLookup=VAR
                                                                Table2Rec@1000000000 : Record 59999;
                                                                Form2@1000000001 : Form 59999;
                                                              BEGIN
                                                                CLEAR(Table2Rec);
                                                                Form2.LOOKUPMODE := TRUE;
                                                                IF Form2.RUNMODAL() = ACTION::LookupOK THEN
                                                                BEGIN
                                                                  Form2.GETRECORD(Table2Rec);
                                                                  Rec."Description From Table2":= Table2Rec.Description;
                                                                  Rec."No Table2 2":= Table2Rec."No.";
                                                                END;
                                                              END;
                                                               }
        { 1000000006;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000005;
                                                     InColumnHeading=Yes }
        { 1000000007;TextBox;0    ;0    ;4400 ;0    ;HorzGlue=Both;
                                                     Editable=No;
                                                     ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr="Description From Table2" }
        { 1000000008;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000007;
                                                     InColumnHeading=Yes }
        { 1000000009;CommandButton;3890;5940;2200;550;
                                                     HorzGlue=Right;
                                                     VertGlue=Bottom;
                                                     Default=Yes;
                                                     PushAction=LookupOK;
                                                     InvalidActionAppearance=Hide }
        { 1000000010;CommandButton;6310;5940;2200;550;
                                                     HorzGlue=Right;
                                                     VertGlue=Bottom;
                                                     Cancel=Yes;
                                                     PushAction=LookupCancel;
                                                     InvalidActionAppearance=Hide }
        { 1000000011;CommandButton;8730;5940;2200;550;
                                                     HorzGlue=Right;
                                                     VertGlue=Bottom;
                                                     PushAction=FormHelp }
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    
    OBJECT Form 59999 FormExample2
    {
      OBJECT-PROPERTIES
      {
        Date=08-06-04;
        Time=17:36:52;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=9790;
        Height=6710;
        TableBoxID=1000000000;
        SourceTable=Table59999;
      }
      CONTROLS
      {
        { 1000000000;TableBox;220 ;220  ;9350 ;5500 ;HorzGlue=Both;
                                                     VertGlue=Both }
        { 1000000001;TextBox;0    ;0    ;1700 ;0    ;ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr="No." }
        { 1000000002;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000001;
                                                     InColumnHeading=Yes }
        { 1000000003;TextBox;0    ;0    ;4400 ;0    ;HorzGlue=Both;
                                                     ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr=Description }
        { 1000000004;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000003;
                                                     InColumnHeading=Yes }
        { 1000000005;CommandButton;2530;5940;2200;550;
                                                     HorzGlue=Right;
                                                     VertGlue=Bottom;
                                                     Default=Yes;
                                                     PushAction=LookupOK;
                                                     InvalidActionAppearance=Hide }
        { 1000000006;CommandButton;4950;5940;2200;550;
                                                     HorzGlue=Right;
                                                     VertGlue=Bottom;
                                                     Cancel=Yes;
                                                     PushAction=LookupCancel;
                                                     InvalidActionAppearance=Hide }
        { 1000000007;CommandButton;7370;5940;2200;550;
                                                     HorzGlue=Right;
                                                     VertGlue=Bottom;
                                                     PushAction=FormHelp }
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    

    Just import it and see how does it work.
  • siyaksiyak Member Posts: 66
    Thanks for that,but my tables and forms looks almost the same as that one.I always use the table relation(T1.No where Name = field T2.name). i don't know why i doesn't do the lookup ](*,)
  • siyaksiyak Member Posts: 66
    I tried to use the field as a flowfield and use the calcfomular the lookup,but it doesn't allow the primary key to be the flowfield!! :-k
  • krzychub83krzychub83 Member Posts: 120
    Hey siyak

    1.
    The table relation on T2
    T2."No." WHERE (Name=FIELD(Name)).
    I just notice, that it should be (in my opinion):
    T1."No." WHERE (Name=FIELD(Name)).
    Because it was on T2.

    2. Check lookup property of this column at the form. You should have <No> (Default Value) or YES, otherwise You will not see lookUp button.

    3. If You can post table and form at this forum (or just the form - I know that this is not always possible). I will try to check then what can be wrong (as quickly as I will be able to do it).
  • siyaksiyak Member Posts: 66
    Can you pleases send me your email address then i'll send it to you
  • siyaksiyak Member Posts: 66
    Hey krzychub83
    thanks for your troubles,i've got it correct,what i have done is delete the code in the Onlookup button(It didn't work because i've just commented it out)then i deleted it and it works =D>
    Thanks again!!!
  • krikikriki Member, Moderator Posts: 9,110
    kriki wrote:
    Remove your code from the OnLookup-trigger.
    The fact that there is some code, makes it that the standard onlookup is NOT triggered. (You may NOT even put some documented line on the trigger!).
    The Validate-trigger will be run when you leave the field after selecting a value with the lookup.

    PS don't forget the LookupFormID-property on the table in which you want to select a value.
    I should have put that phrase in red and in bold.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • siyaksiyak Member Posts: 66
    Thanks Kriki!! i should have read your statement carefully,insead of wasting time doing nothing!! =D>
Sign In or Register to comment.