>While on this subject I had another question. Do you increment the value in the table and then retrieve the new key or do you retrieve the key (+1) and then increment the value in the table. Is there a reason for doing one rather than the other?
You should increment the value in TABLE.DBF first, so if this is succeeding, you can be sure the locking mecanism worked ok.