PC Review


Reply
Thread Tools Rate Thread

Autonumber not going in order

 
 
=?Utf-8?B?Y2luZHk=?=
Guest
Posts: n/a
 
      9th Oct 2006
Autonumber on my table in access skipped from 1017 to 1019 why would this
happen. But in my form it shows 1018
 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      9th Oct 2006
An autonumber value is assigned when you begin to insert a new record. If
you then abandon that record before saving it by pressing the Esc key, or you
delete it after saving it, the autonumber value is not re-used for the next
record unless the database is compacted before the next record is added. An
autonumber is designed purely to guarantee unique values, not sequential
ones. If sequential values are important you should not use an autonumber,
but compute the values. In a single user environment this can be done when
inserting a new record via a form by looking up the last value in the form's
BeforeInsert event procedure and adding 1, e.g.

Me.MyID = Nz(DMax("MyID","MyTable"),0) + 1

In a multi-user environment this is not reliable as conflicts can occur.
I've posted a demo of the commonly used solution to this, which involves
storing the last number in an external database which is opened exclusively
in code to get the next number, at:


http://community.netscape.com/n/pfx/...g=ws-msdevapps


Ken Sheridan
Stafford, England

"cindy" wrote:

> Autonumber on my table in access skipped from 1017 to 1019 why would this
> happen. But in my form it shows 1018


 
Reply With Quote
 
=?Utf-8?B?VG9tIFdpY2tlcmF0aA==?=
Guest
Posts: n/a
 
      10th Oct 2006
Hi Ken,

> ...which involves storing the last number in an external database which is opened exclusively in code to get the next number...


This shouldn't really be necessary. Try the method shown in Form 2, in this
sample database:

http://www.rogersaccesslibrary.com/d...berProblem.mdb


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/ex...tributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

"Ken Sheridan" wrote:

> An autonumber value is assigned when you begin to insert a new record. If
> you then abandon that record before saving it by pressing the Esc key, or you
> delete it after saving it, the autonumber value is not re-used for the next
> record unless the database is compacted before the next record is added. An
> autonumber is designed purely to guarantee unique values, not sequential
> ones. If sequential values are important you should not use an autonumber,
> but compute the values. In a single user environment this can be done when
> inserting a new record via a form by looking up the last value in the form's
> BeforeInsert event procedure and adding 1, e.g.
>
> Me.MyID = Nz(DMax("MyID","MyTable"),0) + 1
>
> In a multi-user environment this is not reliable as conflicts can occur.
> I've posted a demo of the commonly used solution to this, which involves
> storing the last number in an external database which is opened exclusively
> in code to get the next number, at:
>
>
> http://community.netscape.com/n/pfx/...g=ws-msdevapps
>
>
> Ken Sheridan
> Stafford, England

_________________________________________________

> "cindy" wrote:
>
> > Autonumber on my table in access skipped from 1017 to 1019 why would this
> > happen. But in my form it shows 1018

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort Order - Problem with AutoNumber =?Utf-8?B?U29uZHJh?= Microsoft Access Reports 2 7th Mar 2006 05:28 PM
Entry order vs autonumber order? StargateFanFromWork Microsoft Access Getting Started 11 15th Dec 2005 08:11 PM
Recordset Order and Autonumber =?Utf-8?B?Y2hpdG93bjA1?= Microsoft Access Database Table Design 6 23rd Jun 2005 09:04 PM
Re: How do you autonumber in access in alphabetical order? John Vinson Microsoft Access 0 16th Sep 2004 12:31 AM
Re: How do you autonumber in access in alphabetical order? '69 Camaro Microsoft Access 0 15th Sep 2004 08:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:49 PM.