Opens a table-type recordset and then moves through the recordset using the .Edit method to edit a field in the table.
Posted on July 4, 2011
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 'Database - Opens a table-type recordset and then moves through the recordset using the .Edit method to edit a field in the table. Sub EditRecordset() Dim dbs As Database, rst As Recordset Dim strPath As String Set dbs = OpenDatabase(strPath) Set rst = dbs.OpenRecordset("Employees", dbOpenTable) With rst ' Set current index. .Index = "LastName" ' Locate first record. .MoveFirst ' Begin loop. Do Until .EOF If !Title = "Manager" Then ' Enable editing. .Edit ' Change title. !Title = "Executive" ' Save changes. .Update End If ' Locate next record. .MoveNext ' End of loop. Loop ' Close recordset. .Close End With dbs.Close Set dbs = Nothing End Sub |