Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
=TableUpdate()
Message
 
 
To
24/01/2001 13:40:35
Chuck Tripi
University of Wisconsin - Milwaukee
Milwaukee, Wisconsin, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00468066
Message ID:
00468099
Views:
18
Sorry, that was incorrect. The code works only a regular index, not a primary or candidate key field. I never have a primary key field where the user actually enters the data. My PKs are always surrogate and integer that are generated.

If you want to do this, do not bind the control to a field. If you are going to do this regularly, create an ID textbox class with a cSource property:
local lcTable, lcField, lnSelect, lnRec, lnID, lnCount
lcTable = juststem(alltrim(This.cSource))  && mytable.fieldname
lcField = justext(alltrim(This.cSource))
lnSelect = select()
select (lcTable)
lnRec = recno()
lnID = This.Value
count to lnCount for ID = lnID
goto lnRec
if lnCount > 0
   ** Duplicate found
   select (lnSelect)
   return 0
endif
** otherwise the count was 0
replace &lcField with lnID
select (lnSelect)
return .t.
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform