primary key duplicate record is not incremental

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
 
J

John W. Vinson

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?
 
T

Tom van Stiphout

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top