>I want to trap errors generated at the database level from within my application.
>
>For Example : my validation rule for field "QTY" is QTY>0
> Message "Qty cannot be 0"
>
>
>What i am looking is to trap the above validation error in my application. "On Error" is unable to trap the database validation errors.
In my experience, it is difficult to work with field-level and record-level validation rules.
I think it is preferable to put any strict rule you need, into the trigger functions. The advantage is that the triggers are executed only when you issue TableUpdate(). This lets you do any required controls before trying to save.
To make the validation simple in individual forms, I keep my validation rules in a table. When trying to save a record, I just need a single line in the form for validation, for example:
llCanSave = RecordValid("Client")
This will make the function RecordValid() search through the table validation.dbf, for all records where
table = "client", and evaluate the rules. If some condition is not fulfilled, it will show the user the corresponding error message, and return .F.
If you are interested in this approach, I will post the function.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)