G
Guest
I found a lot of information on SoundEx but still don't know how to get it to
work since I'm not a programmer. I inherited this job because someone quit.
Anyway, I have two tables, TableA and TableB. They both have the same fields
of FirstName and LastName. I need to run SoundEx on both of them so they can
then be compared to each other. I read to create a new Module object which I
did called SoundEx but I copied it from the website so I don't know if
anything needs to be changed or where I go from there. Here is the code I
copied and thanks for the help.
Function SoundEx(ByVal S As String) As String
S = UCase$(Trim$(S))
Dim Code As Integer: Code = 0
Dim Last As Integer: Last = 0
Dim R As String: R = ""
Dim i As Long: For i = 1 To Len(S)
Select Case Mid$(S, i, 1)
Case "B", "F", "P", "V"
Code = 1
Case "C", "G", "J", "K", "Q", "S", "X", "Z"
Code = 2
Case "D", "T"
Code = 3
Case "L"
Code = 4
Case "M", "N"
Code = 5
Case "R"
Code = 6
Case Else
Code = 0
End Select
If (i = 1) Then
R = Mid$(S, 1, 1)
ElseIf (Code <> 0 And Code <> Last) Then
R = R & Code
End If
Last = Code
Next i
SoundEx = Mid$(R & "0000", 1, 4)
End Function
work since I'm not a programmer. I inherited this job because someone quit.
Anyway, I have two tables, TableA and TableB. They both have the same fields
of FirstName and LastName. I need to run SoundEx on both of them so they can
then be compared to each other. I read to create a new Module object which I
did called SoundEx but I copied it from the website so I don't know if
anything needs to be changed or where I go from there. Here is the code I
copied and thanks for the help.
Function SoundEx(ByVal S As String) As String
S = UCase$(Trim$(S))
Dim Code As Integer: Code = 0
Dim Last As Integer: Last = 0
Dim R As String: R = ""
Dim i As Long: For i = 1 To Len(S)
Select Case Mid$(S, i, 1)
Case "B", "F", "P", "V"
Code = 1
Case "C", "G", "J", "K", "Q", "S", "X", "Z"
Code = 2
Case "D", "T"
Code = 3
Case "L"
Code = 4
Case "M", "N"
Code = 5
Case "R"
Code = 6
Case Else
Code = 0
End Select
If (i = 1) Then
R = Mid$(S, 1, 1)
ElseIf (Code <> 0 And Code <> Last) Then
R = R & Code
End If
Last = Code
Next i
SoundEx = Mid$(R & "0000", 1, 4)
End Function