>All started from a problem like "Update conflict" on new records - and trying to pass this I put a tableupdate(.T.,.T.) only for new records, after this error was "Invalid trying locking recs in a transaction after take prior locks" (not a exactly transcription of error but there was the message), added a "rollback" in error routine until txnlevel()=0; the code as you see is very simple - things happens in that order:
Cristian,
Isaw all of your messages. In this message you repeat that you got an Update conflict and then fixed it by forcing the tableupdate(), there is your problem.
Update conflict means one user is attempting to update a record that is not the same as what they started with. You need to solve that problem and find out why this is happening. You cannot just "fix it" by forcing the update. That is what is overwriting the existing record.
You effort with curval() is showing you without doubt that you are working with an existing record and not a new one.
You do not need the reccount() call at all. That is not your problem.