A Arvin Meyer Sep 1, 2003 #2 Vijay said: I need the equivalent function for 'replace' in Access query. Click to expand... Here's the one I've been using in queries up until Access 2002 which has one that works: Function ChangeString(strIn As String, strToFind As String, strReplace As String, _ Optional intCount As Variant) As String On Error Resume Next Dim intPlace As Integer Dim intCounter As Integer Dim intStart As Integer If IsMissing(intCount) Then intCount = 32767 intStart = 1 For intCounter = 1 To intCount intPlace = InStr(intStart, strIn, strToFind) If intPlace > 0 Then strIn = Left(strIn, intPlace - 1) & strReplace & Mid(strIn, intPlace + Len(strToFind)) intStart = intPlace + Len(strReplace) + 1 Else Exit For End If Next ChangeString = strIn End Function -- Arvin Meyer, MCP, MVP Microsoft Access Free Access downloads: http://www.datastrat.com http://www.mvps.org/access
Vijay said: I need the equivalent function for 'replace' in Access query. Click to expand... Here's the one I've been using in queries up until Access 2002 which has one that works: Function ChangeString(strIn As String, strToFind As String, strReplace As String, _ Optional intCount As Variant) As String On Error Resume Next Dim intPlace As Integer Dim intCounter As Integer Dim intStart As Integer If IsMissing(intCount) Then intCount = 32767 intStart = 1 For intCounter = 1 To intCount intPlace = InStr(intStart, strIn, strToFind) If intPlace > 0 Then strIn = Left(strIn, intPlace - 1) & strReplace & Mid(strIn, intPlace + Len(strToFind)) intStart = intPlace + Len(strReplace) + 1 Else Exit For End If Next ChangeString = strIn End Function -- Arvin Meyer, MCP, MVP Microsoft Access Free Access downloads: http://www.datastrat.com http://www.mvps.org/access