Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update question

Status
Not open for further replies.

samotek

Technical User
May 9, 2005
197
BG
I have a table where the first field is an autonumber.it is called orderid. As a result of appending i have a row that does not follow the autonumber of the tables.
For example the first row is orderid = 1
and the second row is orderid = 5


I want to update the table so that the row that has orderid = 5 to get the next autonumber, i.e. 2.
How can i make my update query ?
 
You can't do this. The last increment of the Autonumber field is stored with the table. The only way to reset the autonumber is to use VB to do so, but then, what was once a 2 may end up being a 17 or vice versa.

Bottom Line: You should not use autonumbers. They not worth the hassle. I suggest that you Dim a Recordset and use an ordinary counter to update sequentially.

Second Bottom Line: Avoid the grief and avoid AutoNumbers !

Alan J. Volkert
Fleet Services
GE Commercial Finance Capital Solutions
(World's longest company title)
Eden Prairie, MN
 
Auto numbers do not always follow in sequence. If you had records 1,2,3 and 4 then deleted 2,3 and 4 the next record it will create will have a value of 5. I wouldn’t worry to much about trying to get them in sequence. Rule of thumb with auto numbers is that they are used as a unique id. As far as I am aware it is not possible to force this auto number to be the next one in sequence without messing about changing the field data type from autonumber then back again.

Hope this helps,
Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top