Instr/Replace?

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Any sugestions on how to do the following:

Am using the Instr function to search for particular text
within one field and want to be able to replace that text
with other text
 
Why not just use the Replace function?

NewString = Replace(OriginalString, StringToFind, StringToReplaceWith)
 
Hi Tom

Are you using Access 2000 or later? If so, there is a Replace function to
do this.

If you want to be more selective, then you can use code something like this:
iPos = Instr ( strOriginal, strToFind )
strResult = Left( strOriginal, iPos-1 ) & strToReplace _
& Mid( strOriginal, iPos+Len(strToFind) )

In plain English, join together the bit to the left of the string you found,
the new string, and the bit to the right of the string you found.
 
Back
Top