>Hi,
>
>I've got a problem with primary keys. They look like "00001", "00002", etc. Anyways I have run into a situation where I have to reuse them. So for example, if the table contains five records, "00001", "00002", "00003", "00004", "00005" and the user deletes "00003" I wind up with "00001", "00002", "00004", "00005". I have to change it to "00001", "00002", "00003" (used to be 00004), "00004 (used to be 00005). I do this with the following code. The order is set to "tid" which is the Primary key.
>
>scan rest
> replace tid with padl(str(val(tid)-1),5,"0")
>endscan
>
>
>I get a uniqueness of primary key error. I have set deleted on. If I do a pack it works, but I can't do that when the users are using it. Any ideas on how to solve the problem without making the primary key not primary? I am working with a treeview active x control and I am using this as a way to identify an item. The treeview source is a table. When the user deletes one, it is deleted from the table. Then I clear the treeview and add all the items all over again. Maybe there is a better way of doing this? It seemed like overkill when I did it, but can't think of any other way as I need to have the primary key matching the key for that item created by foxPro when the treeview is created.
>
>Thanks!
>Chris
Chris,
Primary keys are for you as an idenifier not for the end user, right ? If so you don't need to make them sequential to work with treeview. IMHO leave as is. Treeview doesn't care they're ordered but just be unique.
Cetin