Use AddNew and specify the field information : Recordset Add Update Delete « Access « VBA / Excel / Access / Word






Use AddNew and specify the field information

 

Public Sub addCustomer()
  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
  With rs
    .AddNew
    .Fields("CompanyName") = "Diner"
    .Fields("Address") = "Road"
    .Fields("City") = "New York"
    .Update
  End With
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 method from Recordset and two arrays to add a new row
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