ADO ActiveCommand Property

Home | About me | EXCEL VB Programming (XL97-2003) | ACCESS Programming | EXCEL VB.Net Programming | EXCEL Spreadsheet Functions Material Management  |  Guestbook
 

ADO AddNew Method

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

After you call this method, the new record will be the current record. 

There are two optional parameters.

Since the parameters are optional, there are two ways to use the AddNew method, with or without the arguments. If you do not use parameters, then you will need to call the Update or UpdateBatch methods. When you use the optional parameters, ADO will automatically perform the update. However, if you are doing batch updates, you will still need to call the UpdateBatch method.

Syntax

objRecordset.AddNew fieldlist,values

 
Parameter Description
fieldlist 
Optional. A field name, or an array of field names, or the numeric position of the fields in the new record
values 
Optional. A value, or an array of values for the fields

Examples

Code:

rs.AddNew "FirstName", "Mary"

Code:

rs.AddNew Array("FirstName", "LastName"), Array("Mary", "Tan")

Code:

varFieldList = Array("FirstName", "LastName")
varValues = Array("Mary", "Tan")
rs.
AddNew varFieldList, varValues

Code:

strFirst = "Merry"
strSecond = "Christmas"
intyear = 2008

... some code
rs.AddNew
rs.Fields("First") = strFirst
rs.Fields("Second") = strSecond
rs.Fields("Year") = intYear
rs.Update