Code from CompList's DevNu Input Validation:
vMSG := "Device # is Required and Must be UNIQUE. If there is no Device #, use '0'";
vMultiple := vMSG + " This Device Number is listed MULTIPLE TIMES, Please Contact your Administator";
vUNID := @Text(@DocumentUniqueID);
vKey := DevNu;
vLookup := @DbLookup ( "":"NoCache"; @DbName; "vwReferenceDevNu"; vKey; 2);
@If ( vKey = ""; @Failure(vMSG); @IsError(vLookup); @Success; DevNu = "0"; @Success; @Elements(vLookup) > 1; @Failure(vMultiple); vUNID = vLookup; @Success; @Failure (vMSG))