Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I edit AutoNumber Column in Access?

I've lost my data in Access base, and I've manage to bring them back but when I copy the values in the table with the AutoNumber Column it increments the numbers. Is there Any way to change it to int and then bring it back to AutoNumber?

like image 699
Pece Avatar asked Jun 24 '10 21:06

Pece


People also ask

Can you edit AutoNumber in access?

You can reset an AutoNumber field value by using a Make-Table query to create a new table that has the same data and then adding a new AutoNumber field.

How do I correct an AutoNumber in access?

In Access 2010 or newer, go to Database Tools and click Compact and Repair Database, and it will automatically reset the ID. I actually much agree with this solution - a simple C+R will reset the autonumber.

How do I change the ID of a column in access?

To change a field name in Access, open the table within which to rename a field in table design view. Then click into the “Field Name” column of the field whose name you wish to change. Type a new name for the field. Then click the “Save” button in the Quick Access toolbar to save your structural changes.

How do you set auto increment column in access?

In the Data Type field, click the drop-down arrow and click AutoNumber. Under Field Properties, in New Values, click Increment to use incrementing numeric values for the primary key, or click Random to use random numbers.


2 Answers

Here is how I managed to do this in Access 2010:

  1. Make a backup of your database. (Just to be safe.)
  2. Right-click on the table in the tables list, and select Export->Excel. Accept all defaults.
  3. Open the table in Excel and make the desired change to the autonumber field.
  4. Open the table and delete all rows
  5. Right-click on table in the tables list, and select Import->Excel
    • In the options, choose "Append to table" and select the table. Accept defaults for all other options

This might not be a viable solution for a large table. I don't think Excel can handle more than around 65K rows.

like image 104
Kip Avatar answered Sep 25 '22 10:09

Kip


Don't copy the data with the user interface, but append it with a query. Because an Autonumber field is just a long integer with a special default value, you can append to it values that already exist. That doesn't work in the UI, but only in SQL.

An Autonumber field has a few other properties that are different from a normal Long Integer field, but in terms of appending data, those are not relevant. One of those properties is that it is not editable once it's populated, and another is that you can have only one in each table.

like image 24
David-W-Fenton Avatar answered Sep 22 '22 10:09

David-W-Fenton