Sub IncreaseEstimateImproved()
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
Dim lngUpdated As Long
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open ("Select * from Products " & _
"WHERE UnitPrice < 30000")
Do Until rst.EOF
lngUpdated = lngUpdated + 1
rst("UnitPrice") = rst("UnitPrice") * 1.1
rst.Update
rst.MoveNext
Loop
Debug.Print lngUpdated & " Records Updated"
rst.Close
Set rst = Nothing
End Sub
|