access vba ado add new record

The solution for “access vba ado add new record” can be found here. The following code will assist you in solving the problem.

‘ Use the References dialog box to set up a reference to the Microsoft ActiveX Data Objects Library

Sub Add_Record()
Dim conn As ADODB.Connection
Dim myRecordset As ADODB.Recordset
Dim strConn As String
strConn = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & CurrentProject.Path & “\mydb.mdb”

Set myRecordset = New ADODB.Recordset
With myRecordset
.Open “Select * from Employees”, _
strConn, adOpenKeyset, adLockOptimistic
.AddNew
!LastName = “Marco”
!FirstName = “Paulo”
!City = “Boston”
.MoveFirst
.Close
End With

Set myRecordset = Nothing
Set conn = Nothing
End Sub

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts