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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing a number sequence in a table column

Status
Not open for further replies.

KerryL

Technical User
May 7, 2001
545
US
I have a table of 945 records. One of the columns is SerID, and it currently starts at 2 and goes up to 1030 or so. However, I need that column to have a numbering sequence starting at 360001 instead of 1.

Is there a way I can re-increment that one column without having to do it manually?
 
TEST something like this on a copy of the table:
Update tblYourTable
SET SerID = SerID + 359999

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
In VBA:
DoCmd.RunSQL "ALTER TABLE myTable ADD COLUMN myID COUNTER(360001,1)"
DoCmd.RunSQL "UPDATE myTable SET SerID=myID"
DoCmd.RunSQL "ALTER TABLE DROP COLUMN myID"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

I put my table (servicesCOPY) and column (ser_id) name in your code:

DoCmd.RunSQL "ALTER TABLE servicesCOPY ADD COLUMN myID COUNTER(360001,1)"
DoCmd.RunSQL "UPDATE servicesCOPY SET ser_id = myID"
DoCmd.RunSQL "ALTER TABLE DROP COLUMN myID"


I tried running it in the ctl-g panel but got a syntax error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top