Function GetNumbersOnly(strIn As String)
Dim j, numOnly
If strIn = "" Then Exit Function
For j = 1 To Len(strIn)
If IsNumeric(mid(strIn, j, 1)) Then
numOnly = numOnly & mid(strIn, j, 1)
End If
Next
GetNumbersOnly = numOnly
End Function
then use the function in your queryFunction GetNumbersOnly(strIn As String)
Dim j, numOnly
If strIn = "" Then Exit Function
For j = 1 To Len(strIn)
If IsNumeric(Mid(strIn, j, 1)) Then
numOnly = numOnly & Mid(strIn, j, 1)
End If
Next
If Len(numOnly) < 10 Then
GetNumbersOnly = "123-" & Format(numOnly, "###-####")
Else
GetNumbersOnly = Format(numOnly, "###-###-####")
End If
End Function
Open in new window
As far as the second part is concerned, I'm not sure what you mean. Are you only looking to add the area code if it is missing?
If that is the case this function will do the job.
Open in new window