lparameters tcTable, tcField, teValue, tiPK local lnCurWA, llReturn, lcExact, leValue assert !empty(tcTable) and !empty(tcField) and !empty(teValue) and !empty(tiPK) ; message 'aDataMgr: Not enough params passed to EnforceUnique()' assert file(iif(empty(justext(tcTable)),forceext(tcTable, 'dbf'), tcTable)) ; message 'aDataMgr: The passed tbale does not exist' lnCurWA = select() lcExact = set('exact') set exact on use (tcTable) again alias EnforceUnique in 0 select EnforceUnique leValue = alltrim(teValue) lcPrimaryKey = dbgetprop(juststem(dbf()),'table','PrimaryKey') *locate for &tcField = teValue and &lcPrimaryKey <> tiPK llReturn = !seek(teValue, 'enforceunique', tcField) or &lcPrimaryKey = tiPK use select (lnCurWA) set exact &lcExact return llReturnThis opens up the table as a different alias and checks the uniquness before the value is even allowed in the table.