Lookup field-query

I have a field(,“Utilised Against Doc No”) which has lookup.

requirement: That lookup leads to the posted invoices.Once i select any posted invoice,the correspoding vendor shipment no value should get reflected on the other field on the same form.I have written the code on On Validate of the field ABC,but the code is not working.

Situation : But when i tried to copy the document number and paste it instead of using lookup,the code is working and the value is getting reflected in the other field.

Code :
purchInvheader.SETRANGE(purchInvheader.“No.”,“Utilised Against Doc No”);
IF purchInvheader.FINDFIRST THEN
PurchReciptHeader.SETRANGE(PurchReciptHeader.“Order No.”,purchInvheader.“Order No.”);
"Vendor Shipment No.":=PurchReciptHeader.“Vendor Shipment No.”;

What could be the reason?Is it correct to write the code on On validate of that field?

I have found the solution for my problem…

The field has some table realation defined as well and the same was written as code on the lookup of the field…That was the reason…

Now i have removed the table relation and have written the code on the lookup of that field and its working fine…