>Hi all,
>
>I have a data entry in a grid, after I entered all data, I want to validate the record for duplicate entry (ex. name) in the "SAVE" command button. I used 5-Buffering. How to do this? Please advice..
>
>Thanks.
>Mike
I see two possibilities here.
One, use a candidate index. This will not allow duplicate values. TableUpdate() will fail; with aerror() you can find out the cause, why the update fails.
Another possibility is to write a small function that accepts the table name, the index name, and the current record number. This function must open the table AGAIN, and search whether the value exists already (but with a different recno()).
Personally, I combine both possibilities. The candidate index gives greater safety for the data, and the UDF makes it easier to give personalized messages. (Using the candidate index alone, the framework will simply say that there is a duplicate value, but not, which field(s) are duplicate.)
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)