dao update field
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

DAO update field

resolvedResolved · Low Priority · Version 2003

replyReply Wed 10 Sep 2008, 13:24Delegate Gillian said...

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?

For upcoming training course dates see: Pricing & availability

replyReply Fri 26 Sep 2008, 12:57Trainer Laura said...

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

 

Please browse our web site to find out more about
introduction access training and other Microsoft training courses.

Access tip:

Duplicating an Entry

To duplicate the entry press CTRL+' (apostrophe)this will copy the contents of the previous entry in the same field.
(Table view, line above) note this also works in Excel.

View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard