Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find and replace a character in a query 1

Status
Not open for further replies.

ovie52

Technical User
Feb 5, 2002
11
0
0
GB
how can i interrogate a field in a query for a certain character and have any occurences of this replaced by another character?
 
Paste this function into a module and call it in the query like so... The example replaces "/" with "*"

select
ReplaceCharacter(FieldName, "/", "*")
from
TableName

Function ReplaceCharacter(strData As String, strFind As String, strReplace As String) As String

While InStr(strData, strFind) > 0
Mid(strData, InStr(strData, strFind)) = strReplace
Wend

ReplaceCharacter = strData

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top