foxpro STUFF function

C

Charlie

Does anyone know of a function in Access 2000 similar to the Foxpro STUFF
function. I want to replace certain text within a portion string but leave
the rest as is.
 
L

Larry Linson

Does anyone know of a function in Access
2000 similar to the Foxpro STUFF
function. I want to replace certain text
within a portion string but leave
the rest as is.

Best to tell us what you'd want the function to do, specifically -- I, for
one, have no FoxPro experience and, thus, don't know what a function
"similar to the FoxPro STUFF" function would do.

If you want to replace some text characters with other text characters, you
should look at Help on the, not surprisingly, Replace function.

For maniuplating strings, looking at Help for the Left, Mid, and Right
functions would be good. To replace the three characters at character
postion 10 - 12 of a 15 character string variable called strOld with the
string in variable strNew, you could use:

strOld = Left$(strOld,9) & strNew & Right$(strOld,3)

strNew doesn't have to be exactly 3 characters, of course.

To obtain the three characters at that position before replacing them

strReplaced = Mid(strOld,10,3)

Larry Linson
Microsoft Access MVP
 
T

Tim Ferguson

Does anyone know of a function in Access 2000 similar to the Foxpro
STUFF function. I want to replace certain text within a portion
string but leave the rest as is.

The Mid() statement does this with one severe restriction: it does not
change the length of the string:

jetSQL = "select date() as today"

Mid(jetSQL, 18, 2) = "yester"

Debug.Print jetSQL ' select date() as yeday

If your replacement text is a different length from the original, then you
are back to normal string slicing with Instr, Left, Mid, and Right.

Hope that helps


Tim F
 
Top