Append Data to Table, Access VBA
In this article I will explain how you can append data to an Access table using VBA.
The article uses the ADODB.Recordset object. In order to use this object you may need to add reference to ADODB object library. For more information on this topic please see the link below:
Values are appended using the Recordset.AddNew method. For more information about this method please see the link below:
As you can see the table has 4 fields:
The following code will initiate an ADODB.Recordset object for the table:
Note: “MyTable1” is the name of the table we want to append the new record to.
New records are added by using the Recordset.AddNew method. The code below will add a new record to the table:
Note: If you are working directly with an Access table, the values displayed in the table will not update automatically. One method to overcome this would be to press “F5”. For more information on this issue please see the link below:
You can download the file and code used in this article from the link below:
- Microsoft MSDN: AddNew Method (ADO)
- Modify Existing Data in Table, Access VBA Recordsets
- Read Data from Table, Access VBA
- Microsoft MSDN: Recordset Object (ADO)
- Delete Record, Access VBA Recordset
- Recordset.AddNew Method VBA Access