primary key duplicate record is not incremental

  • Thread starter Thread starter Gonzalo
  • Start date Start date
G

Gonzalo

Hi,
When I duplicate a record in a form using a command button, the primary key
of the newly created record does not continue from the last one. For example,
if the last one is 1410, and I want to duplicate record 1157, the new one is
a random number (i.e., 545687). Any idea how to fix this?
cheers,
Gonzalo
 
Hi,
When I duplicate a record in a form using a command button, the primary key
of the newly created record does not continue from the last one. For example,
if the last one is 1410, and I want to duplicate record 1157, the new one is
a random number (i.e., 545687). Any idea how to fix this?
cheers,
Gonzalo

Have you set this table's autonumber field (note: a primary key is not
necessarily an autonumber and vice versa) to Random rather than Increment? or
have you Replicated the database, which will do just this?

And if not, could you post your code?
 
On Tue, 9 Mar 2010 16:56:02 -0800, Gonzalo

You could change from AutoNumber to Long Integer and take full
responsibility for generating your own PK value, perhaps in the
BeforeInsert event of your form.
But MUCH better is to treat the PK as "any non-duplicating long
integer", and not care what the value is. And never display this value
to users.
This is a FAQ; you should not have any trouble finding related posts,
e.g. at groups.google.com.

-Tom.
Microsoft Access MVP
 
Back
Top