Autonumber field

Autonumber field

Post by wong » Sun, 09 May 1999 04:00:00



Help me guys

here is my sample code (vb 5)

let say "custid" is a autonumber field.

when I fire "data1.recordset.addnew" this field will increas by 1, right!
My problem is, when I fire "data1.recordset.cancelupdate" and I want to set
the "custid"  back to the previous number so that when I add record again,
the number won't jump.  How can I do that ?

Thanks in advance.


 
 
 

Autonumber field

Post by Doug Steel » Sun, 09 May 1999 04:00:00



> Help me guys

> here is my sample code (vb 5)

> let say "custid" is a autonumber field.

> when I fire "data1.recordset.addnew" this field will increas by 1, right!
> My problem is, when I fire "data1.recordset.cancelupdate" and I want to set
> the "custid"  back to the previous number so that when I add record again,
> the number won't jump.  How can I do that ?

You can't. Autonumbers weren't meant to be "reused" once they've been
used. However, since autonumbers really are only there to be used as
unique IDs for Primary and Foreign Keys, and should never have any
meaning associated with them, that shouldn't be a problem.

> Thanks in advance.



--

Beer, Wine and Database Programming.  What could be better?
Visit "Doug Steele's Beer and Programming Emporium"
http://webhome.idirect.com/~djsteele/

 
 
 

Autonumber field

Post by James Olse » Sun, 09 May 1999 04:00:00


You can't the autonumber field is generated for the transaction. The reason
it can't be reused is because there can run more than one transaction at a
time and they each need and unique number which has to be generated
sequentially - so you won't be able to get a perfect sequential numbering
without gaps.


> Help me guys

> here is my sample code (vb 5)

> let say "custid" is a autonumber field.

> when I fire "data1.recordset.addnew" this field will increas by 1, right!
> My problem is, when I fire "data1.recordset.cancelupdate" and I want to
set
> the "custid"  back to the previous number so that when I add record again,
> the number won't jump.  How can I do that ?

> Thanks in advance.



 
 
 

Autonumber field

Post by Noah Bod » Wed, 12 May 1999 04:00:00



> Help me guys

> here is my sample code (vb 5)

> let say "custid" is a autonumber field.

> when I fire "data1.recordset.addnew" this field will increas by 1, right!
> My problem is, when I fire "data1.recordset.cancelupdate" and I want to set
> the "custid"  back to the previous number so that when I add record again,
> the number won't jump.  How can I do that ?

> Thanks in advance.



Sorry to tell you this cannot be done. The autonumber field is designed so
there can never be the
possibility of duplicate numbers.

->N.

 
 
 

Autonumber field

Post by Edwin Ma » Mon, 17 May 1999 04:00:00


Quote:> You can't the autonumber field is generated for the transaction. The
reason
> it can't be reused is because there can run more than one transaction at a
> time and they each need and unique number which has to be generated
> sequentially - so you won't be able to get a perfect sequential numbering
> without gaps.

Then are there any method to fix this tyoe of problem?? I have a date entry
program that also need to generate a auto incre. no. !!

Thanks
Edwin

 
 
 

1. Adding value to field that is linked to autonumber field

I got this problem:

I have dbgrid that has bound into datacontrol that has "sql..innerjoin..where."
-query as recordsource. So how can I add a new value in dbgrid so that the
value in a field that has linked to a autonumber field is added with the number
that is in the autonumber field ?  

Please help ...

2. FourGen: Hierarchy level

3. Newbie Update field in DB using AutoNumber field

4. Enumerating stored procedures & their columns

5. Find which field is Autonumber field type by code

6. Borland Database Engine: Paradox and DbiDeleteRecord

7. Autonumber fields in sql 2000

8. Update with Group By & Having Clause

9. Replication ID / Autonumber field

10. cycle autonumber field

11. Appending records with an (autonumber) field?

12. Create an autonumber field

13. Autonumber field problem