Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace Function for Global Table Changes

Status
Not open for further replies.

rjstephan

Technical User
Mar 15, 2002
15
US
In Access 2002 how do I use the VBA Replace function to search all fields in a table and change all occurences of "ABC" to "XYZ"?
Thanks in advance.
 
Create a recordset the way you want to ADO or DAO.

Loop through the recordset in the field you want to alter.

Use Replace as follows:

Do until .eof

.fields("myField")=Replace(.fields("myField"),"ABC","XYZ")

.MoveNext

Loop

Should do it. I haven't tried it.
 
I wanted to avoid looping thru all possible fields individually. If you use the Replace command off the menu in a table you can search and replace all fields in the entire table at once -- that's what I would like to do with a function. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top