>I am almost there
>
>I created the primary key
>
>Now when try to uptadate the table
>and the item already exists, the message appears:
>
>"the uniqueness is been violated"
>
>How can I prevent this message, or simply
>prevent the record from being updated ?
The idea of a primary or candidate key is precisely to avoid duplicates.
If you already have duplicates in the table, you must clean them up BEFORE creating the index.
Afterwards, there are several things you can do.
For example, when you try to save the data with TableUpdate() - I am assuming that you use buffering - if TableUpdate() returns .F., check for the error, with the function aerror(). If it is a duplicate, tell the user this, so the user has to change the data and try to save again.
Of course, TableUpdate() may fail for a variety of reasons, for example, the table is read-only, or some other rule is violated.
A simple validation is somewhat like this:
if not TableUpdate()
local laError
aerror(laError)
MessageBox("Error saving data, error #" + trans(laError(1);
+ " - " + laError(2))
endif
Of course, you can check the individual error numbers, and give more specific error messages in some cases.
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)