I am trying to use a replace function in VBA to run a query but I dont know how to reference it in VBA in order for it to work.
Here is my code where I ahve tried to use to get rid of certain characters from people's name:
Any ideas what I am doing wrong with the replace function??
Here is my code where I ahve tried to use to get rid of certain characters from people's name:
Code:
Public Function GetName(AnyText As String, bFlag As Boolean) As String
GetName = Replace(AnyText, "*", "")
Dim nIndex As Integer
nIndex = InStr(AnyText, "/")
If nIndex = 0 Then
If bFlag = False Then 'Surname
GetName = ""
Else
GetName = AnyText 'Forename
End If
Exit Function
Else
If bFlag = True Then
GetName = Left(AnyText, nIndex - 1)
Else
GetName = Mid(AnyText, nIndex + 1)
End If
End If
End Function
Any ideas what I am doing wrong with the replace function??