How to assign a sequential number to a file

I want to assign a sequential number as the primary key to a table.  I want
to do this by reading the LAST record right before posting the record and
add one to this field to create the new key.  The problem is that I am using
data aware controls and reading a new record will lose the values currently
in the controls.  Any suggestions?

thanks