A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

primary key duplicate record is not incremental



 
 
Thread Tools Display Modes
  #1  
Old March 10th, 2010, 12:56 AM posted to microsoft.public.access.forms
Gonzalo
external usenet poster
 
Posts: 21
Default primary key duplicate record is not incremental

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

  #2  
Old March 10th, 2010, 01:38 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default primary key duplicate record is not incremental

On Tue, 9 Mar 2010 16:56:02 -0800, Gonzalo
wrote:

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

John W. Vinson [MVP]
  #3  
Old March 10th, 2010, 02:18 AM posted to microsoft.public.access.forms
Tom van Stiphout[_2_]
external usenet poster
 
Posts: 1,653
Default primary key duplicate record is not incremental

On Tue, 9 Mar 2010 16:56:02 -0800, Gonzalo
wrote:

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


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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:13 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.