>
Dim dbsNorthwind As Database, rstEmployees As Recordset
Dim strSelect as String
Set dbsNorthwind = DBEngine.Workspaces(0).OpenDatabase("Northwind.mdb")
strSelect = "Select * FROM Employees WHERE Title = 'Sales Representative' "
' Open recordset.
Set rstEmployees = dbsNorthwind.OpenRecordset(strSelect)
Do Until rstEmployees.EOF    ' Begin loop.
    With rstEmployees
    .Edit    ' Enable editing.
    !Title = "Account Executive"    ' Change title.
    .Update    ' Save changes.
    .MoveNext    ' Locate next record.
    End With
Loop    ' End of loop.
rstEmployees.Close    ' Close table.
dbsNorthwind.Close
Tip
Using an update query to change job titles might be
more efficient. For example, you could use the following code to
achieve the same results:
Dim strSelect as String
strSelect = "Update Employees Set Title = 'Account Executive' " _
    "WHERE Title = 'Sales Representative' "
dbsNorthwind.Execute strSelect
Example (Microsoft Access)
The following example uses the MoveLast
method to populate the Recordset object so the number of
records can be counted. The MoveFirst method then moves
the current record pointer to the first record in the Recordset
object. The procedure prompts the user to enter a record number,
then sets a bookmark for that record.
Sub MoveToRecord()
    Dim dbs As Database, rst As Recordset, intI As Integer
    Dim strNumber As String, strBookmark As String
    ' Return Database variable pointing to current database.
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("Orders")
    ' Populate Recordset object.
    rst.MoveLast
    ' Return to first record.
    rst.MoveFirst
    strNumber = InputBox("Please enter record number.")
    ' Check that number is within Recordset object.
    If strNumber <= rst.RecordCount And rst.Bookmarkable Then
        For intI = 1 To strNumber
            rst.MoveNext
        Next intI
        strBookmark = rst.Bookmark
    End If
End Sub
Example (Microsoft Excel)
This example replaces values in the CON_TITLE field
of the records in the Customer recordset in the NWINDEX.MDB
database, and then it displays how many replacements were made.
To create the NWINDEX.MDB database, run the
Microsoft Excel example for the CreateDatabase method.
Dim db As Database, rs As Recordset, sQLText As String
Set db = Workspaces(0).OpenDatabase(Application.Path & "\NWINDEX.MDB")
sQLText = "SELECT * FROM  Customer WHERE " _
    & "CON_TITLE =  'Sales Representative';"
Set rs = db.OpenRecordset(sQLText)
i = 0
Do Until rs.EOF
    With rs
        .Edit
        .Fields("CON_TITLE").Value = "Account Executive"
        .Update
        .MoveNext
    End With
    i = i + 1
Loop
MsgBox i & " replacements were made."
rs.Close
db.Close