473,503 Members | 11,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is the largest "auto number" that can exist in an Access database? How to reset autonumber to start at 1?

Hi:

I know this is a strange question, but I have inherited a system where files are copied
and records re auto numbered (as an index field) )frequently, and I am wondering how high
the number can go without the system crashing.

An ancillary question is how one resets an auto number so that the sequence starts again
at 1.

In the case of this file, the auto number field serves no useful purpose except as an
index, and identifier of a unique record, so no problem with renumbering the records
provided one does not try and create two identical numbers (in which case the system
throws up all over you!).

Regards

John Baker

Nov 13 '05 #1
16 20440
Maximum size for an autonumber is 2,147,483,647 and the smallest it can be
is -2,147,483,648.
One way to reset it back to zero is to delete all records in the table and
then compact the database.

Jeff
"John Baker" <Ba******@Verizon.net> wrote in message
news:i6********************************@4ax.com...
Hi:

I know this is a strange question, but I have inherited a system where files are copied and records re auto numbered (as an index field) )frequently, and I am wondering how high the number can go without the system crashing.

An ancillary question is how one resets an auto number so that the sequence starts again at 1.

In the case of this file, the auto number field serves no useful purpose except as an index, and identifier of a unique record, so no problem with renumbering the records provided one does not try and create two identical numbers (in which case the system throws up all over you!).

Regards

John Baker

Nov 13 '05 #2
Thanks.. its good to know I can do that.

Is there any programmatic way to reset it? I would almost like to reset it every time I
use it!

Best

John
"Jeff Smith" <No***@Not.This.Address> wrote:
Maximum size for an autonumber is 2,147,483,647 and the smallest it can be
is -2,147,483,648.
One way to reset it back to zero is to delete all records in the table and
then compact the database.

Jeff
"John Baker" <Ba******@Verizon.net> wrote in message
news:i6********************************@4ax.com.. .
Hi:

I know this is a strange question, but I have inherited a system where

files are copied
and records re auto numbered (as an index field) )frequently, and I am

wondering how high
the number can go without the system crashing.

An ancillary question is how one resets an auto number so that the

sequence starts again
at 1.

In the case of this file, the auto number field serves no useful purpose

except as an
index, and identifier of a unique record, so no problem with renumbering

the records
provided one does not try and create two identical numbers (in which case

the system
throws up all over you!).

Regards

John Baker


Nov 13 '05 #3
If you're even thinking you might want to reset it,
don't use an autonumber.
Autonumbers are not meant to be meaningful, just unique.

"John Baker" <Ba******@Verizon.net> wrote in message
news:lt********************************@4ax.com...
Thanks.. its good to know I can do that.

Is there any programmatic way to reset it? I would almost like to reset it every time I use it!

Best

John
"Jeff Smith" <No***@Not.This.Address> wrote:
Maximum size for an autonumber is 2,147,483,647 and the smallest it can beis -2,147,483,648.
One way to reset it back to zero is to delete all records in the table andthen compact the database.

Jeff
"John Baker" <Ba******@Verizon.net> wrote in message
news:i6********************************@4ax.com.. .
Hi:

I know this is a strange question, but I have inherited a system where

files are copied
and records re auto numbered (as an index field) )frequently, and I am

wondering how high
the number can go without the system crashing.

An ancillary question is how one resets an auto number so that the

sequence starts again
at 1.

In the case of this file, the auto number field serves no useful
purposeexcept as an
index, and identifier of a unique record, so no problem with
renumberingthe records
provided one does not try and create two identical numbers (in which
casethe system
throws up all over you!).

Regards

John Baker

Nov 13 '05 #4
Jeff Smith wrote:
Maximum size for an autonumber is 2,147,483,647


Out of interest, when using increment, what happens to the next record
after that number? Does it roll over into the negative?

Back in the old DOS days, I wrote a program to calculate prime numbers,
as I remember my 12MHz 286 was rather slow so for speed I wrote 4
separate bits to do it, going from integer, long, single then double so
that when say the integer got over 32767 it would error and the error
trap would resume to the long bit and carry on. This worked in the IDE
(MS Basic PDS 7.1) but when compiled to a stand alone .exe file it would
not error but would wrap into negative numbers, no matter if I used x87
emulation[1] or alternate math libs.

[1] Well I didn't have a 287 co-pro on there.

--

\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\

Nov 13 '05 #5
Trevor,
If you create a new table (or compact an empty one), then append a record
with the autonumber field set to 2,147,483,647 then start entering records
manually the first manually entered record has an autonumber field value of
1 and then they increment as normal (2, 3, 4, 5 etc).

If, however, you create a new table (or compact an empty one), then append
a record with the autonumber field set to 2,147,483,646 then start entering
records manually the first manually entered record has an autonumber field
value of 2,147,483,647 but from then on they change to negative values,
-2147483648, -2147483647, -2147483646 and so on; note they are still
incrementing

(Tested in XP)
--
Terry Kreft
MVP Microsoft Access
"Trevor Best" <nospam@localhost> wrote in message
news:41***********************@auth.uk.news.easyne t.net...
Jeff Smith wrote:
Maximum size for an autonumber is 2,147,483,647
Out of interest, when using increment, what happens to the next record
after that number? Does it roll over into the negative?

<SNIP> [1] Well I didn't have a 287 co-pro on there.

--

\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\

Nov 13 '05 #6
John Baker <Ba******@Verizon.net> wrote in
news:i6********************************@4ax.com:
I know this is a strange question, but I have inherited a system
where files are copied and records re auto numbered (as an index
field) )frequently, and I am wondering how high the number can go
without the system crashing.

An ancillary question is how one resets an auto number so that the
sequence starts again at 1.

In the case of this file, the auto number field serves no useful
purpose except as an index, and identifier of a unique record, so
no problem with renumbering the records provided one does not try
and create two identical numbers (in which case the system throws
up all over you!).


Others have already pointed out that if you actually care about the
values of the autonumber, then you're mis-using it.

Let me also point out that there's nothing magical about an
autonumber: it is just a special kind of default value. If you want
to re-use numbers, simply append your record with the autonumber set
to a value that is presently unused.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #7
Normal autonumbers are long numbers. See the specification for Long.

If the table is empty, compacting the database will reset the auto
number to 1.

(david)

"John Baker" <Ba******@Verizon.net> wrote in message
news:i6********************************@4ax.com...
Hi:

I know this is a strange question, but I have inherited a system where files are copied and records re auto numbered (as an index field) )frequently, and I am wondering how high the number can go without the system crashing.

An ancillary question is how one resets an auto number so that the sequence starts again at 1.

In the case of this file, the auto number field serves no useful purpose except as an index, and identifier of a unique record, so no problem with renumbering the records provided one does not try and create two identical numbers (in which case the system throws up all over you!).

Regards

John Baker

Nov 13 '05 #8
Terry:

If I understand what your saying correctly, overflowing an auto number will cause no
problems at all. In other words rather than the maximum number of UNIQUE auto numbers
being 2,147,483,647, it is in fact twice that, since you have the negative value AND the
positive one.

Have I understood that correctly?

Best

John

"Terry Kreft" <te*********@mps.co.uk> wrote:
Trevor,
If you create a new table (or compact an empty one), then append a record
with the autonumber field set to 2,147,483,647 then start entering records
manually the first manually entered record has an autonumber field value of
1 and then they increment as normal (2, 3, 4, 5 etc).

If, however, you create a new table (or compact an empty one), then append
a record with the autonumber field set to 2,147,483,646 then start entering
records manually the first manually entered record has an autonumber field
value of 2,147,483,647 but from then on they change to negative values,
-2147483648, -2147483647, -2147483646 and so on; note they are still
incrementing

(Tested in XP)


Nov 13 '05 #9
Yes, you have the full range of an unsigned long to play with.

--
Terry Kreft
MVP Microsoft Access
"John Baker" <Ba******@Verizon.net> wrote in message
news:rd********************************@4ax.com...
Terry:

If I understand what your saying correctly, overflowing an auto number will cause no problems at all. In other words rather than the maximum number of UNIQUE auto numbers being 2,147,483,647, it is in fact twice that, since you have the negative value AND the positive one.

Have I understood that correctly?

Best

John

"Terry Kreft" <te*********@mps.co.uk> wrote:
Trevor,
If you create a new table (or compact an empty one), then append a recordwith the autonumber field set to 2,147,483,647 then start entering recordsmanually the first manually entered record has an autonumber field value of1 and then they increment as normal (2, 3, 4, 5 etc).

If, however, you create a new table (or compact an empty one), then appenda record with the autonumber field set to 2,147,483,646 then start enteringrecords manually the first manually entered record has an autonumber fieldvalue of 2,147,483,647 but from then on they change to negative values,
-2147483648, -2147483647, -2147483646 and so on; note they are still
incrementing

(Tested in XP)

Nov 13 '05 #10
Terry Kreft wrote:
Yes, you have the full range of an unsigned long to play with.


Yes, just mentally add 4 binary billion to the negative numbers to get
the number you want :-)

ISTR when there were a few more BASIC compilers around, one of them
(can't remember which) had an integer type called a cardinal, which was
just an unsigned int like you can have in C.

--

\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\

Nov 13 '05 #11
Thanks guys. Since I don't expect the system to exist without major changes for more than
3-4 years, and the table I am concerned about changes about once a month, and only
contains 300 items, I don't think I am going to have a problem.

Appreciate your input on this.

Incidentally, if I did want to reset the number back to zero, I gather I can do it by
emptying the table and compressing. I tried that specifically by copying the contents of
the table to another table (same format different name) emptying the original table,
compressing, and then copying the old data back to the new table without the auto add
number (which is an index key). For some reason the OLD number keeps turning up.

Any suggestions?

Best

John Baker

Trevor Best <nospam@localhost> wrote:
Terry Kreft wrote:
Yes, you have the full range of an unsigned long to play with.


Yes, just mentally add 4 binary billion to the negative numbers to get
the number you want :-)

ISTR when there were a few more BASIC compilers around, one of them
(can't remember which) had an integer type called a cardinal, which was
just an unsigned int like you can have in C.


Nov 13 '05 #12
The other way to do it is
Copy from "source" table to "temp" table
Delete "source" table
Copy from "temp" table to "source" table (structure only)
Use an Append query to add rows to the "source" table from the "temp"
table.

The big disadvantage of this is you'll need to remove and recreate any links
between the "source" table and other tables in your db.

Compacting the database should reset the autonumber so I don't understand
why this is not happening.
--
Terry Kreft
MVP Microsoft Access
"John Baker" <Ba******@Verizon.net> wrote in message
news:e8********************************@4ax.com...
Thanks guys. Since I don't expect the system to exist without major changes for more than 3-4 years, and the table I am concerned about changes about once a month, and only contains 300 items, I don't think I am going to have a problem.

Appreciate your input on this.

Incidentally, if I did want to reset the number back to zero, I gather I can do it by emptying the table and compressing. I tried that specifically by copying the contents of the table to another table (same format different name) emptying the original table, compressing, and then copying the old data back to the new table without the auto add number (which is an index key). For some reason the OLD number keeps turning up.
Any suggestions?

Best

John Baker

Trevor Best <nospam@localhost> wrote:
Terry Kreft wrote:
Yes, you have the full range of an unsigned long to play with.


Yes, just mentally add 4 binary billion to the negative numbers to get
the number you want :-)

ISTR when there were a few more BASIC compilers around, one of them
(can't remember which) had an integer type called a cardinal, which was
just an unsigned int like you can have in C.

Nov 13 '05 #13

The orginal question has still not been answered. What happens when the
table contains 4294967295 records (or rather the highest Autonumber is
4294967295). What is the next one?

If we regard the Autonumber as an unsigned long the maximum is
4294967295 (or maybe 4294967296!!). So what comes next?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #14
"Ron Devonish" <no*****@nowhere.com> wrote in message
news:41**********************@news.newsgroups.ws.. .

The orginal question has still not been answered. What happens when the
table contains 4294967295 records (or rather the highest Autonumber is
4294967295). What is the next one?

If we regard the Autonumber as an unsigned long the maximum is
4294967295 (or maybe 4294967296!!). So what comes next?


I would suspect an error would be raised, but even with a one field table
you will never have this many AutoNumbers consumed unless you have huge
quantities of records that are created, then deleted, then more added.

In a typical application you will hit the file size limit long before going
through this many numbers.

If you had a non-typical app where the aforementioned was happening then
AutoNumber would be a poor choice for a field in the same way that using a
long integer field to store phone numbers is a poor choice.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #15
Ron Devonish wrote:
The orginal question has still not been answered. What happens when the
table contains 4294967295 records (or rather the highest Autonumber is
4294967295). What is the next one?

If we regard the Autonumber as an unsigned long the maximum is
4294967295 (or maybe 4294967296!!). So what comes next?


I'd agree with Rick, as you have a 2GB mdb file size limit you couldn't
fill those numbers anyway. A long integer is 4 bytes, this will give you
half a billion records minus Access' overheads if you had just the
autonumber field in a table.

If you were in a situation where you'd regularly delete records and
append new and use up all the numbers that way then I would reconsider
using an autonumber in there anyway (it's probably meaningless to the
computer let alone a human in that instance), or at least set it to a
random number.

The range of a Long Integer (even just the positive side) should be
adequate for any Access database, if it's not then you should reconsider
either the database engine or the design of the database.

--

\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\

Nov 13 '05 #16
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Usually, when a positive number reaches it's limit, and its data type
allows negative numbers, it will switch over to negatives. IOW:

4294967295 will "increment" to -4294967294

The next numbers will be -4294967293, -4294967292, etc.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQS+S7IechKqOuFEgEQLcvwCeKzt3D0JMEETZ5bNlCgUgoP rojgUAoIab
u/mqBa/xAej8gX+1mI0VII8W
=ZNY0
-----END PGP SIGNATURE-----
Rick Brandt wrote:
"Ron Devonish" <no*****@nowhere.com> wrote in message
news:41**********************@news.newsgroups.ws.. .
The orginal question has still not been answered. What happens when the
table contains 4294967295 records (or rather the highest Autonumber is
4294967295). What is the next one?

If we regard the Autonumber as an unsigned long the maximum is
4294967295 (or maybe 4294967296!!). So what comes next?

I would suspect an error would be raised, but even with a one field table
you will never have this many AutoNumbers consumed unless you have huge
quantities of records that are created, then deleted, then more added.

In a typical application you will hit the file size limit long before going
through this many numbers.

If you had a non-typical app where the aforementioned was happening then
AutoNumber would be a poor choice for a field in the same way that using a
long integer field to store phone numbers is a poor choice.


Nov 13 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
4577
by: J. Campbell | last post by:
When the bitwise NOT operator, is placed in front of an integer variable type (bool, char, short, int, long), the return value is a signed int, regardless of the variable type. An example can be...
3
3087
by: matt | last post by:
Greetings: I appoligize if I'm asking a question that's already been answered in the group - I've scoured for about two hours and I can't find a solution. I also appoligize if I over complicate...
1
2106
by: ComputerGuyCJ | last post by:
I have an application that I've used click-once deployment to publish out to a shared network path. From there I installed the app on a few client machines, including my own. Since then I published...
9
18817
by: Beowulf | last post by:
I was having this problem: http://groups.google.com/group/microsoft.public.sqlserver.server/msg/e36e423972323378?dmode=source with it taking an inordinate amount of time to enumerate the...
0
1639
barbk
by: barbk | last post by:
Hey all, In DB2 v9 is it possible to have an auto generated number field within a primary key that is a combination of multiple fields? For example resv locn sale_no 1234 789...
2
23093
by: VSS | last post by:
Hello, I need to know what is the maximum number of records Access can hold? I need approx. 6 million records, do you know if Access can hold this amount? Thank you everyone.
3
17217
by: Simon van Beek | last post by:
Dear reader, What can be wrong in my ComboBox, the property "Auto Expand" is set to Yes, but by typing in the ComboBox it doesn't expand. Is this because the source of the ComboBox is a...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7294
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3183
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1523
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
403
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.