Hi All,
I am trying to run this code (in an Access XP module) that I copied off of the MS Support Site to convert the CR character used in Microsoft Excel to the CR character used in Microsoft Access (Knowledge Base Article 115576). I followed all of the directions, and even tried looking for help, but still get the error. I have no References listed as missing, please help if you can. Thanks.
-Code starts below-
Public Function ChangeStr(s As Variant, a As String, n As String, c As Integer) As Variant
' This function changes all substrings "a" and string "s"
' to "n." The parameter "c" has the same function as in the
' InStr() function.
Dim temp As String, pos As Integer
temp = ""
If IsNull(s) Then
ChangeStr = Null
Exit Function
End If
If a = "" Or s = "" Then
ChangeStr = s
Exit Function
End If
pos = InStr(1, s, a, c)
While pos > 0
temp = temp & Mid$(s, 1, pos - 1) & n
s = Right$(s, Len(s) - pos - Len(a) + 1)
pos = InStr(1, s, a, c)
Wend
ChangeStr = temp & s
End Function
I am trying to run this code (in an Access XP module) that I copied off of the MS Support Site to convert the CR character used in Microsoft Excel to the CR character used in Microsoft Access (Knowledge Base Article 115576). I followed all of the directions, and even tried looking for help, but still get the error. I have no References listed as missing, please help if you can. Thanks.
-Code starts below-
Public Function ChangeStr(s As Variant, a As String, n As String, c As Integer) As Variant
' This function changes all substrings "a" and string "s"
' to "n." The parameter "c" has the same function as in the
' InStr() function.
Dim temp As String, pos As Integer
temp = ""
If IsNull(s) Then
ChangeStr = Null
Exit Function
End If
If a = "" Or s = "" Then
ChangeStr = s
Exit Function
End If
pos = InStr(1, s, a, c)
While pos > 0
temp = temp & Mid$(s, 1, pos - 1) & n
s = Right$(s, Len(s) - pos - Len(a) + 1)
pos = InStr(1, s, a, c)
Wend
ChangeStr = temp & s
End Function