dao update field

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » DAO update field

DAO update field

resolvedResolved · Low Priority · Version 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:

Creating Parameter wildcard queries

To creat a parameter query that also uses a wildcard, in the query design type in like []+*.

View all Access hints and tips


Server loaded in 0.07 secs.