You can check a duplicate key with the function I am including at the end. You should also change the index to Candidate or Primary, since this provides greates safety against violation of rules.
Regards, Hilmar.
FUNCTION DuplicateKey(tcTag, tcTable, txPkExpression)
local lnSelect, lcDbf, lnRecno, txEvalExpr, llDuplicate, lcExpression, lcOrder, llWorkOnView
llWorkOnView = not empty(tcTable)
lnSelect = select()
lcDbf = iif(empty(tcTable), dbf(), tcTable)
lnRecno = recno()
lcOrder = order()
if not llWorkOnView
set order to (tcTag)
lcExpression = key()
else
select 0
use (lcDbf) order (tcTag) again
lcExpression = key()
use
select (lnSelect)
endif
txEvalExpr = eval(lcExpression)
select 0
use (lcDbf) order (tcTag) again
seek txEvalExpr
if found() and (llWorkOnView and eval(tag(GetPkNum())) = txPkExpression;
or not llWorkOnView and recno() = lnRecno)
skip
endif
llDuplicate = (eval(lcExpression) = txEvalExpr)
use
select (lnSelect)
set order to (lcOrder)
return llDuplicate
ENDFUNC
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)