Feb 5, 2002 #1 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?
how can i interrogate a field in a query for a certain character and have any occurences of this replaced by another character?
Feb 5, 2002 1 #2 tomschafer Technical User Aug 9, 2001 474 0 0 US 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 Upvote 0 Downvote
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