Hi Joao,
>I get the fowling error in the valid event,
>'No database is open or set as the current database' in the line
> lcPrimaryKey = dbgetprop........ and then
>'variable lcPrimaryKey does not exist'
That means your database isn't open. Do you have a main data base for the application? Is this table apart of the database, and does this table have a primary index? If so, you need to open the database sometime before this happens. I usually open it up at the beginning of my app (OPEN DATABASE is the code) Other wise, use this (this uses the Recno() instead of a primary Key):
local lnCurWA, llReturn, lcExact, leValue, lnRecno()
with This
lnCurWA = select()
lcExact = set('exact')
set exact on
lnRecno = recno(juststem(.ControlSource))
use (dbf(juststem(.ControlSource))) again alias EnforceUnique in 0
select EnforceUnique
llReturn = !seek(.Value, 'enforceunique', justext(.ControlSource)) or Recno() = lnRecno
use
select (lnCurWA)
set exact &lcExact
endwith
if !llreturn
MessageB('Value is not unique')
endif
return iif(llReturn, .T., 0)
Does this work?