April 2006
Beginner
1114 pages
98h 16m
English
recordset.AddNew
Adds a new record to the recordset. The following code adds a new record to the Employees table in the Northwind Traders sample database using cell values on the current worksheet:
Dim strDbPath As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
strDbPath = "C:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb"
Set db = OpenDatabase(strDbPath)
Set rs = db.OpenRecordset("Employees")
rs.AddNew
rs!LastName = ActiveSheet.Range("B4")
rs!FirstName = ActiveSheet.Range("C4")
rs.UpdateRead now
Unlock full access