Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

dao update field

ResolvedVersion 2003

Gillian has attended:
Access VBA course
Excel Advanced course

DAO update field

Is there a VBA DOA method to update a field in a table recorset? I am updating a field base don the trimmed value of another field in the table.
I can do it by using tabledef and calling on SQL to do it, but I need to know how to do it without SQL because I want to use the VBA 'replace' method tp update another field.

Is this possible with DAO? Should I put the table into an array instead?

RE: DAO update field

Hi Gillian

Thanks for the question.

DAO will do what you want to do I think. Below is a simple example of walking through a complete table updating a field.


Sub EditRow_DAO()
Dim DB As DAO.Database
Dim tblItems As DAO.Recordset
'get the current database and recordset to work with
Set DB = CurrentDb
Set tblItems = DB.OpenRecordset("tbl_Items")
Do Until tblItems.EOF
tblItems.Fields("TrimmedName") = Trim(tblItems.Fields("OriginalName"))
tblItems.Update
tblItems.MoveNext
Loop

'close the recordset and database
tblItems.Close
DB.Close
End Sub


Does that example help?

Laura GB

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Access tip:

Label printing

You can create a report in Access for printing labels All you have to do is is click New under the Reports object and then select Label Wizard and follow the steps

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.