AddNew Method

The AddNew method on a Recordset object creates a new record for an updatable Recordset object.

recordset.AddNew Fields, Values
 

Parameters

Fields
This optional parameter specifies a single name or an array of names or ordinal positions of the fields in the new record.
Values
This optional parameter specifies a single value or an array of values for the fields in the new record. If Fields is an array, Values must also be an array with the same number of members; otherwise, an error occurs. The order of field names must match the order of field values in each array.

Remarks

The AddNew method is used to create and initialize a new record. The Supports method can be used with adAddNew to verify whether records can be added to the current Recordset object.

After the AddNew method is called, the new record becomes the current record and remains current after the Update method is called. If the Recordset object does not support bookmarks, you may not be able to access the new record after you move to another record. Depending on your cursor type, you may need to call the Requery method to make the new record accessible.

If AddNew is called while editing the current record or while adding a new record, ADO calls the Update method to save any changes and then creates the new record.

The behavior of the AddNew method depends on the updating mode of the Recordset object and whether or not the Fields and Values arguments are passed.

In immediate update mode, the OLE DB Provider writes changes to the underlying data source after the Update method is called. In immediate update mode, calling the AddNew method without arguments sets the EditMode property to adEditAdd. The OLE DB Provider caches any field value changes locally. Calling the Update method posts the new record to the database and resets the EditMode property to adEditNone. If the Fields and Values arguments are passed, ADO immediately posts the new record to the database (no Update call is necessary) and the EditMode property value does not change (adEditNone).

In batch update mode, the OLE DB Provider caches multiple changes and writes them to the underlying data source only when the UpdateBatch method is called. In batch update mode, calling the AddNew method without arguments sets the EditMode property to adEditAdd. The OLE DB Provider caches any field value changes locally. Calling the Update method adds the new record to the current Recordset object and resets the EditMode property to adEditNone, but the OLE DB Provider does not post the changes to the underlying database until the UpdateBatch method is called. If the Fields and Values arguments are passed, ADO sends the new record to the provider for storage in a cache and the UpdateBatch method must be called to post the new record to the underlying database.