Not sure why you need a trigger on open page ..I'd validate when a user enters a line say when Qty/price entered using OnAfterCalcLineAmount as below code unit:
begin
if PurchaseLine.Type = PurchaseLine.Type::Item then begin
If (PurchaseLine."Location Code" = '') then begin
if PurchaseLine.FindFirst() then
error('Must have location code');
end;
end;
end;