AutoNumber Field Not Working

M

Mike Thomas

In Access 2000, I have a table with an autonumber/ primary key field.

Somehow, it has messed up its next number function. When I add a new
record, the autonumber field is displaying a 27, when it should be putting
in someting much larger.

Of course, the record cannot be saved because of the key violation.

Is there a way to fix this?

Many thanks
Mike Thomas
 
O

oozyscab via AccessMonster.com

Try compacting and repairing the database. This usually resets all of the
autonum counters. If that doesn't work, there is code that you can use to
explicitly set the value of the counter.

Here is an example of how I used it...

Dim db As DAO.Database
Dim strReset As String

Set db = CurrentDb

strReset = "ALTER TABLE tblVendor ALTER COLUMN VendorIDPK COUNTER (200, 1)
;"
db.Execute strReset, dbFailOnError

You'll want to replace the table and column names with your own and change
the 200 to the counter value that you need.

Cheers,
Eric
 
Top