For instance by using LookUpOK.
In OnLookUp trigger of the field, you can try this kind of code :
SourceTable.RESET;
SourceTable.SETFILTER(Field1,'%1',Filter1);
IF FORM.RUNMODAL(Form ID,,SourceTable) = ACTION::LookupOK THEN
"My Field" := SourceTable."Source Field";
My candle burns by both ends, it will not last the night,
But oh my foes and oh my friends, it gives a lovely light
when i have used the tablerelation properties then system generate the error Msg.
Error Msg is:-
The field below must be included in the table's primary key.
So, the table relation prop. is for PK fields.
so if you need the table relation and an lookup to an other field in the relat. Table, use the OnLookup Trigger of the field.
But the LookUpOK function works even if the field is not included in the primary key.
Try this :
Create a form based on Integer, Create a var TestVarDec (Decimal).
Add a control on your form which Source is this TestVarDec.
On your control, on trigger "OnLookup(VAR Text : Text[1024]) : Boolean"
Write the next code (GLEntry is a record var based on table 17.
GLEntry.RESET;
IF FORM.RUNMODAL(20,GLEntry) = ACTION::LookupOK THEN
TestVarDec := GLENtry.Amount;
I just tried, it works fine
My candle burns by both ends, it will not last the night,
But oh my foes and oh my friends, it gives a lovely light
Hi Mrigya,
take a textbox with Source Expression CustName
<YourControl> - OnLookup(VAR Text : Text[1024];) : Boolean
global variables
CustName --- Code --- 50
CustRec --- Record --- Customer
CustFrm --- Form --- Customer List
CustRec.RESET;
// CustRec.SETRANGE("Your Field",FromValue,ToValue); // to set filter on lookup form
IF CustRec.FINDSET THEN
BEGIN
CustFrm.SETTABLEVIEW(CustRec);
CustFrm.LOOKUPMODE(TRUE);
IF CustFrm.RUNMODAL = ACTION::LookupOK THEN
BEGIN
CustFrm.GETRECORD(CustRec);
CustName := CustRec.Name;
END;
END;
CLEAR(CustFrm);
I hope, you got the Idea...!! O:)
Sandeep Prajapati Technical Consultant, MS Dynamics NAV
Comments
do you use the TableRelation property in a table and there comes the error or what?
In OnLookUp trigger of the field, you can try this kind of code :
But oh my foes and oh my friends, it gives a lovely light
Error Msg is:-
The field below must be included in the table's primary key.
field:- External document no.
table: Cust. Ledger Entry
so if you need the table relation and an lookup to an other field in the relat. Table, use the OnLookup Trigger of the field.
But oh my foes and oh my friends, it gives a lovely light
Try this :
Create a form based on Integer, Create a var TestVarDec (Decimal).
Add a control on your form which Source is this TestVarDec.
On your control, on trigger "OnLookup(VAR Text : Text[1024]) : Boolean"
Write the next code (GLEntry is a record var based on table 17.
I just tried, it works fine
But oh my foes and oh my friends, it gives a lovely light
take a textbox with Source Expression CustName
<YourControl> - OnLookup(VAR Text : Text[1024];) : Boolean
global variables
CustName --- Code --- 50
CustRec --- Record --- Customer
CustFrm --- Form --- Customer List
I hope, you got the Idea...!! O:)
Technical Consultant, MS Dynamics NAV