Quickest way to replace characters in a string

Quickest way to replace characters in a string

Post by Ivor » Wed, 15 Sep 2004 18:20:48


Rather than running a find and replace macro or a routine,
Does anyone know a quicker way (running time) to replace
characters in a string i.e. replace a string of Ys and Ns
with 1s and spaces e.g. 'YYNNYNNY' goes to '11 1 1'.

TIA
Ivor
 
 
 

Quickest way to replace characters in a string

Post by Steve Scha » Thu, 16 Sep 2004 03:39:58

Ivor

One option would be a couple of Update Queries using the Replace()
function (assuming Access 2000 SR3 or later version). Do one query to
update YourText to...
Replace([YourText],"Y","1")
... and another to update YourText to...
Replace([YourText],"N"," ")
Then, if you like, you can run these Update Queries in a macro using a
couple of OpenQuery actions. If you do this, you may want to put a
SetWarnings/No action before the first OpenQuery, to supress the display
of the action query confirmation messages.

--
Steve Schapel, Microsoft Access MVP