>That means that every time I delete a record a PACK must follow? Why is SET DELETED ON not hiding the duplicate key ?
A primary (or cnadidate) index requires unique key values. The fact that DELETED is ON does not change the fact that the key exists. If VFP allowed you to add a duplicate key, then you would have a problem if DELETED was turned off.
You can use a surrogate primary key as a one solution. Since you always assign a new key when adding a record, you don't get uniqueness violations.
Another way to handle the problem is to keep DELETED OFF. If you are displaying a deleted record, disable the ability to edit it and give the user an obvious indication of its deleted status. If the user tries to add a key that has been deleted, let them know that a deleted record already exists and give them the option to undelete the record.
You can also change the key value before deleteing a record. FOr example a numeric key could be made negative when the record is deleted.
The index could be made a composite key that includes the deleted status as part of the key.