The unique formatting is available as a static property of an element. If you want it to be dynamic, you need to check if the value in the element is unique when your other element is set to "receipt". The @IsUnique call can check that at when the user leaves the element, but before they commit the form.
The first argument to @IsUnique is the element to check. In your case this would be "lotNo." The second argument is the value to check for. Since you want to check the value currently in lotNo, this could also be lotNo. If you test this on a form that already has a committed value, it will test as non-unique because @IsUnique was designed to test values before they get used so as to prevent the use of non-unique values being committed.
In the element exit event:
if(transaction = "receipt")
{
if(@IsUnique(lotNo, lotNo) = 0)
{
@MsgBox("tsk tsk")
}
}
This code could use a flag and maybe a NotifyForm command to prevent the record from being committed if the condition is not met. And, as I said before, you may want to revisit the condition if they go back and change "transaction".
You may want to consider using a subroutine, so that you can call that subroutine if either transacton or lotNo change.