Hi kevin,
>How can I have a different message appear when a Primary Key is violated.
You can do this in two ways:
1. A general error handling routine
2. Use Record (or table) buffering and use TABLEUPDATE(2) in combination with AERROR() to determine if an index uniqueness viloation has ocorred.
Solution 1. is not that practical, because it is lot more difficult to recover from such an error.
Personally I use more or less the following approach:
IF !TABLEUPDATE(2, .T., cAlias)
=AERROR(aErr1)
DO CASE
CASE aErr1[1,1]=1884
.... Show a messagebox or resolve it in code
CASE aErr1[1,1]=1539 AND INLIST(aErr1[1,5],1,2)
..... handle it
CASE aErr1[1,1]=1539 AND aErr1[1,5]=3 AND TYPE("gaerrors[1,9]")="C"
..... handle it
ENDCASE
ENDIF
Of course its better to build it in your framework classes so you can reuse this strategy.
As for all the guys trying to get you to use surrogate keys, please read Message #
491025 (and surrounding messages) before you take a decision.
Walter,