Lookup
siyak
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
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
0
Comments
-
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!0 -
i've trid that,but still doesn't do the lookup0
-
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 help0
-
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
Did you do this?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!0 -
Yes i did it,but it removes the lookup button ](*,)0
-
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:0
-
:-k
TableRelation: T1."No."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)).
Put code only in onValidate() trigger.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
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.0 -
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 ](*,)0
-
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!! :-k0
-
Hey siyak
1.
I just notice, that it should be (in my opinion):The table relation on T2
T2."No." WHERE (Name=FIELD(Name)).
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).0 -
Can you pleases send me your email address then i'll send it to you0
-
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!!!0 -
I should have put that phrase in red and in bold.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.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Thanks Kriki!! i should have read your statement carefully,insead of wasting time doing nothing!! =D>0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions