fix Access runtime Error 3022

Summary:

This blog is completely dedicated to provide the solution regarding one of the very common MS Access errors. i.e Access Error 3022: “The changes you requested to the table were not successful “. To know how to fix this specific error code you must try the following fixes mentioned in this post.

Practical Scenario :

I get Access Error 3022: The changes you requested to the table were not successful because they would create duplicate values in the primary index, primary key, or relationship…

The code is an edit mode that I created that deletes all records from the table where criteria are found. There can be unlimited records based on what is in tblMulti.

There is a typical PK in each and it is set to autonumber no duplicates allowed. 

I cannot find where I went wrong. Can you please look at this and point me in a direction to fix it?

About Access Run-time error ‘3022’:

You may fetch this ms access error when you try to insert new record in access table that already contained an Autonumber field. This specific issue occurs in Microsoft Office Access 2007 or in Microsoft Office Access 2003.

At that time the application throws the following error message:

The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.

SCREENSHOT OF THE ERROR:

The Changes You Requested To The Table Were Not Successful

Note: check out that the table may not have any relationship or indexes.

The Access “Run-time error ‘3022’: The changes you requested to the table were not successful usually occurs when they would create duplicate values in the index, primary key, or relationship.

So you need to change the data in the field that contain duplicate data, remove the index or redefine the index to permit duplicate entries and try again. This problem generally arises at the time of saving changes to a report or generating a report.

Cause

  • Well the most common cause of occurrence of this Access error ‘3022’ is corruption in the specification set.
  • Access database was compacted somehow.
  • Table contain autonumber field which is not correctly reseeded.
  • You must have installed Microsoft Jet 4.0 Database Engine Service Pack 8 (SP8).
  • May be you have Appended the data from linked table 1 to linked table 2 by using the Current Databaseoption in place of Another Database Delete the record from linked table 1 and re-append the exact record from linked table 2 using the Current Database option.

Resolution To Fix “The Changes You Requested To The Table Were Not Successful” error

You need to compact the Current Spec Set see compacting an FRx Database. If these compacting procedures fail, then contact the FRx Support to repair the file. But if it succeeds, but the report component still gives the error message then try exporting the component into a new specification set or recreate the component.

Workaround 1::

Fix  The Changes You Requested To The Table Were Not Successful in Access 2003/2007

To fix this issue in Access 2007 database you need to re-create the append queries in dbFrontEnd.accdb database. To do this, tap to the Append in the Query Type group on the Design tab, and then click to the Another Database option.

Access 2007

To fix this issue in Access 2007 database you need to re-create the append queries in the dbFrontEnd.mdb database.  For this, just make a click in the Append Query present on the Query menu in the query design view and then click Another database.

To fix this issue, the very first thing you need to do is compact the database and after then reset the Autonumber field seed. To compact the database, follow these steps:

  1. Start your Access application.
  2. After then Open the Access database. Note: If this opens the Security Warning dialog box, then tap to the Open option.

In Access 2007

  • You need to tap to the Microsoft Office Button, now go to the Manage option, and then click Compact and Repair Database.

In Access 2003

  • Go to the tool menu, and click to the Database Utilities, and click Compact and Repair Database.
  1. If you see such Security Warning dialog box, then tap to the Open option.

In order to reset the Autonumber field seed, you can try one of the following methods:

Method 1: Use a Data Definition query

Open database that has the table in Access 2007.

  1. Go to the Create tab; click Query Design in the Other
  2. In the Show Table dialog box, tap to the close option.
  3. Now go to the Design tab, click SQL viewin the Results
  4. Type the following in the Query1window:

    ALTER TABLE TableNameALTER COLUMN AutoNumFieldNameCOUNTER(iMaxID,1);

    Note:

TableName is placeholder for the name of the table. AutoNumFieldName is a placeholder for the name of the Autonumber field. iMaxID is a placeholder for the current maximum value in the field plus 1.

  1. From the Designtab, tap to the Run option in Results

Access 2003

  1. Click queries under objects in the database window.
  2. After then click to the New, and click to the Design View and then click OK.
  3. In the opened Show Tabledialog box, click to the close option.
  4. From the query menu click SQL Specific, and then click Data Definition.
  5. From the Data Definition Query window, type the following command. ALTER TABLE TableNameALTER COLUMN AutoNumFieldNameCOUNTER(iMaxID,1); Note:

Here the TableName clearly signifies the name of the table. And AutoNumFieldName indicates the name of Autonumber field. Whereas, the iMaxID represent the current maximum value in the field plus 1.

  1. On the Query menu, click Run.

Also Read:

How To Fix Access Forms And Reports Not Showing Image Issue

How To Resolve Access Database Record Locking Issue During Multi-User Access?

Method 2: Run Visual Basic for Applications code

Access 2007

  • Now go to the Create tab, click the down arrow under Macro and then click Module.

Access 2003

  • Go to the database window, click Modules under Objects, and then click New.
  1. After then in the Visual Basic Editor paste the following code.

Sub ResetAuto()

Dim iMaxID As Long
Dim sqlFixID As String

  iMaxID = DMax(“<AutonumberFieldName>”, “<TableName>”) + 1
                       
  sqlFixID = “ALTER TABLE <TableName> ALTER COLUMN <AutonumberFieldName> COUNTER(” & <iMaxID> & “,1)”
        
  DoCmd.RunSQL sqlFixID

End Sub 

Note The placeholder <AutonumberFieldName> represents the name of the Autonumber field. The placeholder <TableName> represents the name of the table.

  1. From the run menu, click Run Sub/UserForm.

Note:

Close table before you use either of the method. You don’t need to save the query or the module after you successfully used any the above two method

Workaround 2::

In order to resolve the Error ‘3022’: The Changes you Requested to the Table were not Successful in access 2013/2016 database. User need to design the tables to eliminate the possibility of entering duplicate values in primary key field or field that uses a unique index.

If the used primary key needs to support duplicate values, then you should remove the current primary key and add an AutoNumber field to your table which works as a primary key.

To remove the primary key

Removing the primary key won’t delete the field or fields from your table. Rather it, removes the primary key designation from those field.

It also removes the index of the primary key that was created for the primary key.

  1. Before deleting the primary key, make sure that it doesn’t contain in any table relationships. If you still try to remove the primary key which contains the relationships, Access warns you that you must delete the relation first.
  1. Now in the navigation pane, make a right click to the table in which you want to remove the primary key and tap to the Design View option.
  2. Tap to the current row selector for latest primary key.
  3. If primary key contains single field, click the row selector for that field.
  4. But if it consists of multiple fields, hit the row selector for any field in the primary key.
  5. Now go to the Design tab in the Tools group and click to the Primary Key option.

After doing this complete procedure you will see that the key indicator is removed from the field or fields that you previously specified as the primary key.

To Add An Autonumber Primary Key

When any user creates a new table in the datasheet view, Access by default creates a primary key for you and assigns it the AutoNumber data type.

 If you have an existing table to which you want to add a primary key field then opens it up in the design view:

  • Go to the Navigation Pane, and make a right click to the table which you want to add the primary key after then hit the Design View.
  • Now locate the first empty row in table design grid.
  • In the Field Name column, assign some name.
  • In the Data Type column hit the drop-down arrow and tap to the AutoNumber option.
  • Within the Field Properties, in New Values, click to the Increment option to use incremental numeric values for the primary key, or click Random to use random numbers.

You may want to see the indexes for table to evaluate their impact on performance, or to ensure that particular fields are indexed.

Wrap Up:

Hopefully all the above mentioned manual fixes help you in resolving this MS Access run-time error 3022. After using these fixes, do share your opinions in your comment section.

How To Fix Ms Access Error ‘3022’: “The Changes You Requested To The Table Were Not Successful “?