Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trapping Primary Key Violation
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01076240
Message ID:
01076247
Views:
17
>This should be really simple, but I'm looking for a good way to trap a violation of a primary key error.
>
>I have a form in which the user has access to the primary key. So when they add it, as long is it's unique the table will update correctly (using tableupdate(). But if they add or change it to a duplicate I get a "uniqueness of vendornum is violated" message. Which is great. All I want to do at this point is display my own error and return them to the field where they can correct the error.
>
>What's the best way to do this? Thanks!
>
>(I'm this is on a form with optimistic row buffering)

In Error Event of the form put:
LPARAMETERS nError, cMethod, nLine
IF nError == 1884
**   You get your error
ELSE
  *** Execute normal Error handler
ENDIF
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform