Trim or Left Function??

As this is only a one off exercise I would move from trying to update your list in one fail swoop, I would run the update/replace for each replacement required. Using this method at least you can check that each replacement has worked.

If you want to do this code you will need the following


Code:
Public Function Revisions(StrFind As String, StrReplace As String)

Dim Rs As DAO.Recordset
Set Rs = CurrentDb.OpenRecordset("[COLOR="YellowGreen"]YourTableNameHere[/COLOR]")

Do Until Rs.EOF
   Rs.Edit
   Rs("[COLOR="yellowgreen"]YourFieldNameHere[/COLOR]") = Replace(Rs("[COLOR="yellowgreen"]YourFieldNameHere[/COLOR]"),StrFind,StrReplace)
   Rs.Update
   Rs.MoveNext
Loop
Rs.Close
Set Rs = Nothing
Debug.Print "Done"

End Function


Then in your immediate window type in

Code:
?Revisions("Shirker","Worker")

Repeat for all variations until you have cleaned up your database

David
 
Thanks. Looks good.

What do you mean by the immediate window actually? Where do I type in the code?
 
Whilst in the module where you added the function you can press ctrl+g to open up a small pane at the bottom of the screen. This is known as the immediate window (don't ask why) you can run functions from their.

To do this you enter a ? followed by a function name and any parameters that you need to send. So as per my example it would be

? Revisions(BadString,"LookForWhatString","ReplaceWithThisString")

By putting in the line Debug.Print "Done" when the code has been completed it echos "Done" on the next line in the immediate window. This is purely to let you know that the function has completed.

David
 

Users who are viewing this thread

Back
Top Bottom