Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Uniqueness Voilated
Message
From
08/10/1997 16:41:28
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00053723
Message ID:
00053781
Views:
28
>>>How could I prevent the error message "...Uniqueness Voilated..."
>>>while updating record into a table.
>>>Anyway to handle/prevent? I would like to control this error message
>>>with the MESSAGEBOX() function. How to detect this error? Thanks.
>>
>>I guess, the source of message is some candidate or primary index. If you want to trap it, use standard 'ON ERROR do something' approach (AERROR works good here).
>
>I had a similiar problem, and unfortunately worked around it to get the system on the floor by making the index
>regular from primary. I found primary indexes weren't checked until the user tried to save the record
>and then it bombed the system.
>
>This now allows dups, and I thought I could solve it with some code in the error event. I wrote the code,
>and it, too, messes up the dataentry process. I put it in the valid event for the text field but it just errors
>out the whole record rather than allowing the user another chance.
>
>Any general comments would be greatly appreciated.

I like this:
**** cmdSave commandbutton
Local lErrorflag
**** control values validation code, unique id generation, etc.
ON ERROR lErrorflag=.t.
Insert Into ....
ON ERROR
if lErrorflag=.t.
=aerror(aErrorinfo)
DO CASE
CASE aErrorinfo[1]=....
**** try to recycle if uniqueness violated by deleted record
CASE aErrorinfo[1]=....
CASE aErrorinfo[1]=....
OTHERWISE
=messagebox("Cannot Save: "+aErrorinfo[2],0+16,oApp.msgtitle)
return
ENDCASE
endif
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform