This gets tougher to do using a table based solution since Access trims off
trailing spaces.
You could try entering
space + CO + underscore in the update to field " CO_"
and then using the replace function to change the underscore character to a
space.
UPDATE YourTable INNER JOIN TranslationTable
ON YourTable.SomeField
Like "*" & MyReplace(TranslationTable.Abbreviation," ","_") & "*"
SET YourTable.SomeField =
MyReplace([SomeField],[Abbreviation],MyReplace(Nz([Expansion],""),"_"," "))
Another (and probably better) option would be to always require a leading and
trailing space in the replace. In this case you would not enter " CO _" as the
the item (abbreviation) to be replaced. You would use just "CO". To make
this work you would need to
-- add a leading and trailing space to the field you are replacing
-- add a leading and trailing space to the Abbreviation
-- add a leading and trailing space to the expansion
-- trim any leading and trailing spaces from the result
UPDATE YourTable INNER JOIN TranslationTable
ON YourTable.SomeField Like "*" & TranslationTable.Abbreviation & "*"
SET YourTable.SomeField =
Trim(MyReplace(" " & [SomeField] & " "," " & [Abbreviation] & " "," " &
Nz([Expansion],"") & " "))
As usual, BACK UP YOUR DATA before you try this.
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
Hi John,
I'm sorry but i got another problem.. Can I capture the value of
(Space)Co(Space) Instead of Co?? I want to replace a string like Connie & Co
I just want to replace The "Co" but instead of replace "Co" only it replace
the both "Co"nnie and "Co" itself. I hope my question is clear enough..
Thanks..
: