PDA

View Full Version : Character replace function


Kal
04-01-2008, 11:09 AM
Hi guys I have the following function to replace specific charcters within a string. However it only seems to be replacing the character amphersands and not apostrophes.

Can anyone help me work out why my function doesn't work correctly.

Thanks



Function DataPrep(qwerty)

If NOT isNull(qwerty) then

DataPrep = Replace(qwerty, "'", "-")
DataPrep = Replace(qwerty, "&", "and")

End if

End Function



Code to call the function



DataPrep(rs("sitename"))

Brandoe85
04-01-2008, 07:37 PM
You need to use the Replaced value in your second statement:

Function DataPrep(qwerty)

If NOT isNull(qwerty) then

DataPrep = Replace(qwerty, "'", "-")
DataPrep = Replace(DataPrep, "&", "and")

End if

End Function


Good luck

Kal
04-02-2008, 08:56 AM
Thanks for that works great.