Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Easy way to have PK start at 62001 ?

I have a table that has an autonumber Primary Key.  Is there an easy way to make the first number start at 62001?
Avatar of ste5an
ste5an
Flag of Germany image

As it is a surrogate key, there should never be need for this:

ALTER TABLE TableThatIncrements
   ALTER COLUMN Id AUTOINCREMENT(62001, 1)

Open in new window

Try this SQL:
ALTER TABLE [YourTable] ALTER COLUMN [YourIdColumn] AUTOINCREMENT (62001,1)

Open in new window

to expand on pcelba's solution:
alt F11 to vba
alt v i   to immediate window
make sure your table is closed
type the following and hit enter.  (Change Table1 and ID to match your table
docmd.runsql "ALTER TABLE [table1] ALTER COLUMN [id] COUNTER (62001,1)"



there should never be need for this
Whilst the reason for starting at 62001 isn't given if you are trying to keep this PK aligned to some other table or numbering system then you probably need a different approach such as a foreign key and leave the PK to being just that.
Avatar of SteveL13

ASKER

rberke:  Getting "Invalid data type"
pcelba: Getting "Invalid field data type"

What Access version do you have available?
And what is the data type of your ID column?
Access 365
Auto-number field.
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial