Thank you for pointing out the fallacies of calling accepttext() from losefocus(). You are of course absolutely right for all of the reasons. So, in summary:
Call the checking of the reference number from itemchanged() event using the "data" argument.
Do NOT call AcceptText() in losefocus() event!!!
If the user will mostly be tabbing to another column in the same datawindow you can probably leave it at that. If on the other hand this is the only column, then you need something else to trigger the check of whether the record already exists. Perhaps a small command button, which will AcceptText()
(Seem to remember a similar somewhat odd example or lab in the Advanced Datawindow Training Course many moons ago)