updtaes


S

steve

I wrote a bit of code that looks at a table and updates a
particular field (below). However, I'm looking for a way
to look at the entire record...not just an individual
field and make updates based on criteria. Any suggestions
appreciated....
Thanks,

Function seekchange()
Dim db As Database
Dim rst As Recordset

Set db = CurrentDb()
Set rst = db.OpenRecordset("ARI0204")

rst.MoveFirst
Do Until rst.EOF
If rst!Field10 = "ri" Then
rst.Edit
rst!Field10 = "Account Executive"
rst.Update
End If
rst.MoveNext
Loop
rst.Close
End Function
 
Ad

Advertisements

C

Chris

You can update many fields between the .Edit and .Update
methods.


db As Database
Dim rst As Recordset

Set db = CurrentDb()
Set rst = db.OpenRecordset("ARI0204")

rst.MoveFirst
Do Until rst.EOF
rst.Edit

If rst!Field10 = "ri" Then
rst!Field10 = "Account Executive"
End If
If rst!Field11 = "MM" Then rst!Field10 = "Mickey Mouse"
End If
rst.Update

rst.MoveNext
Loop
rst.Close
End Function
 
Ad

Advertisements

J

John Vinson

I wrote a bit of code that looks at a table and updates a
particular field (below). However, I'm looking for a way
to look at the entire record...not just an individual
field and make updates based on criteria. Any suggestions
appreciated....

It is not necessary to use any VBA code at all. Just use an Update
query; apply any criteria you like, and update whichever fields you
like. The Query can be executed from code if you wish, but it's better
to use a stored query than to open a recordset.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top