Use AddNew method from Recordset and two arrays to add a new row : Recordset Add Update Delete « Access « VBA / Excel / Access / Word






Use AddNew method from Recordset and two arrays to add a new row

 
Public Sub addCustomerArray()

  Dim conn As ADODB.Connection
  Dim rs As ADODB.Recordset

  Set conn = CurrentProject.Connection
  Set rs = New ADODB.Recordset

  rs.Open "tblCompany", conn, adOpenDynamic, adLockOptimistic, adCmdTable
    
  varfields = Array("CompanyName", "Address", "City")
  varValues = Array("A", "Road", "B")

  rs.AddNew varfields, varValues
  rs.Update

End Sub

 








Related examples in the same category

1.Add new a row to recordset
2.Adding a New Record to a Recordset
3.Use AddNew and specify the field information
4.Adding a New Record to a Table
5.Modifying a Record
6.Performing Batch Updates
7.Delete row for a certain criteria
8.Deleting a Record
9.Call update method from Recordset
10.Call delete method in Recordset
11.Check the Recordset affected