LOCAL laErrors[1], llRetVal, loUpd, lcMsgTxt
llretVal = .T.
AERROR( laErrors )
DO CASE
CASE laErrors[1] = 1539 && Trigger failed
DO CASE
CASE laErrors[5] = 1 && Insert Trigger
lcMsgTxt = 'Unable to add new record. Insert trigger failed!'
llRetVal = .F.
CASE laErrors[5] = 2 && Update Trigger
lcMsgTxt = 'Unable to save record. Update trigger failed!'
llRetVal = .F.
CASE laErrors[5] = 3 && Delete Trigger
lcMsgTxt = 'Unable to Delete record. Delete trigger failed'
llRetVal = .F.
ENDCASE
CASE laErrors[1] = 1585 && Update Conflict
*** updres is my custom form class that handles update
*** conflicts and either resolves them or displays
*** them to the user for intervention. If the conflicts
*** can be resolved without user intervention, the
*** form class merely return .F. from its init() and
*** is never seen
loUpd = CREATEOBJECT( 'updres', ThisForm.DataSessionID, .cPrimaryAlias )
IF TYPE( 'loUpd' ) = "O" AND ! ISNULL( loUpd )
loUpd.Show()
ENDIF
llRetVal = .T.
CASE laErrors[1] = 1884 && Duplicate key
lcMsgTxt = 'Unable to Save. Duplicate key!'
llRetVal = .F.
OTHERWISE
lcMsgTxt = 'Sorry. Unable to save data right now.'
llRetVal = .F.
ENDCASE
IF NOT llRetVal
MESSAGEBOX( lcMsgTxt, 16, 'Unable to Save Your Changes' )
ENDIF
RETURN llRetVal