Next Autoincrement number 
Author Message
 Next Autoincrement number

When you erase a table that has an autoincrement field, the field continues
on with the next number in the autoincrement sequence when  new record is
added. Is there a way to determine what that next number will be? I don't
think there's a way to reinitialize the sequence with 1.

TIA,

Jerry



Thu, 30 Oct 2003 02:10:19 GMT  
 Next Autoincrement number
There is no way that I know of to get the next increment before it is added.
You can however, set the counter back to one on an empty table by compacting
the database after the table is empty.

HTH
Del



Fri, 31 Oct 2003 23:29:10 GMT  
 Next Autoincrement number
Thanks for the info. I can look at the current value and add 1 to it for the
next increment. That works fine unless the table is empty, of course. I was
hoping for a way to work around this without the overhead of compacting.
Guess not.

Thanks...

Jerry


Quote:
> There is no way that I know of to get the next increment before it is
added.
> You can however, set the counter back to one on an empty table by
compacting
> the database after the table is empty.

> HTH
> Del



Sat, 01 Nov 2003 04:06:27 GMT  
 Next Autoincrement number
Bear in mind that the next increment +1 is NOT neccesarily the value you
will get when you add the next row.

If you begin a transaction, insert 10 rows and then roll back the
transaction, or delete the last 10 inserts, you loose those values.
That is to say

Id currently shows 1000
do 10 inserts
Id now shows 1010
Roll back the transaction, or delete the last 10 inserts

Maximum value in the ID column now shows at 1000, so you might expect the
next insert to have id value of 1001, but in fact it will be 1011, because
the autoincrement cannot take account of rollbacks and deletes. It cant for
obvious reasons.
Id=1000
User 1 inserts 10 rows
ids=1000-1009
User 2 inserts 10 rows
ids = 1010 - 1019
User 1 rolls back his transaction.
User 2 inserts 1 more row. The database cant reuse 1000-1009 because user2
has already gone beyond that.


Quote:
> Thanks for the info. I can look at the current value and add 1 to it for
the
> next increment. That works fine unless the table is empty, of course. I
was
> hoping for a way to work around this without the overhead of compacting.
> Guess not.

> Thanks...

> Jerry



> > There is no way that I know of to get the next increment before it is
> added.
> > You can however, set the counter back to one on an empty table by
> compacting
> > the database after the table is empty.

> > HTH
> > Del



Mon, 03 Nov 2003 03:16:20 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Resolving autoincrement fields next value

2. Get next value of AutoIncrement (SQL) ?

3. Autoincrement revision number ?

4. How to make build autoincrement version or build number

5. Generating next P. O. number

6. Generating next P.O. number

7. Next page section break with continuous page numbering

8. Macro to: SaveAs, assigning next sequential number as filename

9. Accumulating numbers using the four next statement

10. On Error Resume Next (but Only with Specific Error, like Err.Number = 70)

11. How to find the next available number?

12. How to find first/next available number in a table

 

 
Powered by phpBB® Forum Software