I have a text field that looks like 070-71000-5400 and I would like a function or macro to remove the "-" so that the end result looks like 070710005400
If you have Access 2K or above then the Replace function can be used as in [tt]
txtField = Replace ("070-71000-5400", "-", "")
[/tt]
If you're in Access '97 or below then use the following [tt]
Public Function ReplaceIt(ByVal myString As String, _
ByVal strFind As String, _
ByVal strReplaceWith As String) As String
Dim n As Integer
Dim pos As Integer
Dim strTemp As String
strTemp = myString
If Len(strTemp) = 0 Then
ReplaceIt = ""
Else
pos = 1
n = InStr(pos, strTemp, strFind)
Do While n > 0
pos = n + Len(strReplaceWith)
strTemp = Left$(strTemp, n - 1) & strReplaceWith & Mid$(strTemp, n + Len(strFind))
n = InStr(pos, strTemp, strFind)
Loop
ReplaceIt = strTemp
End If
End Function
[/tt]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.