Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Right Recno()
Message
From
02/11/1999 15:52:35
 
 
To
01/11/1999 23:07:53
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00285239
Message ID:
00285706
Views:
18
Hi Joao,

>I'm a biginner in VFP, i understand what you said, but when a open the rule that comes with Expression builder and i don't now what i do.

What you do is store it in a procedure or class method then do in the Rule:

IsKeyUnique(tcTheTableName, tcNameField, teValue, tiPK)

With data this may look like:

IsKeyUnique("clientes", "c_codigo", c_codigo, id_PK)

This will fire anytime the field is changed, if you want to validate it just when you put it in the textbox (easier!), put this in the Valid() event of your textbox and forget about the DataBase rule:
local lnCurWA, llReturn, lcExact, leValue, liPK

with This
	lnCurWA = select()
	lcExact = set('exact')
	set exact on
	lcPrimaryKey = dbgetprop(juststem(dbf(juststem(.ControlSource))),'table','PrimaryKey')
	liPK = eval(forceext(.ControlSource, lcPrimaryKey))

	use (dbf(juststem(.ControlSource))) again alias EnforceUnique in 0
	select EnforceUnique

	llReturn = !seek(.Value, 'enforceunique', justext(.ControlSource)) or eval(lcPrimaryKey) = liPK

	use
	select (lnCurWA)
	set exact &lcExact

endwith
if !llreturn
	MessageB('Value is not unique')
endif
return iif(llReturn, .T., 0)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform