setrange on lookup

a field has to lookup into a form basing on the previous value it has. say ‘custnum’ is the field which has to lookup into salesheader table and field “selltocustomer no”. when i do lookup, the form should show only records which are equivalent to the number present when the look up was made.

What is the problem?

hi kumar, Can u explain ur problem in detail…i.e.,on which form u want the lookup field? TAA

Hi! As far as I understand you, your TableRelation property value <“Sales Header”.“Sell-to Customer No.” WHERE (Sell-to Customer No.=FIELD(CustNum))> isn’t working because of error notified as “The field below must be included in the table’s primary key. Field: Sell-to Customer No. Table: Sales Header”. Is it right? The way to solve this is to define OnLookup trigger shown as follows: VAR SalesHeader@1000000000 : Record 36; BEGIN SalesHeader.RESET; SalesHeader.SETFILTER(SalesHeader.“Sell-to Customer No.”, CustNum); IF FORM.RUNMODAL(FORM::“Sales List”, SalesHeader)= ACTION::LookupOK THEN BEGIN MESSAGE(‘Done!’); END; END; Regards, Yuri Pokusaev IBS, Senior Consultant NCPS, NCSD +7(095)987-8080