Hi all,
I have a query which appears to run ok and I start getting a result but then
Access just stops responding, I 've tried running it o/nite when there is
little network traffic but the same. My sql for the query is as follows
SELECT initials.Surname, initials.Suburb, PUBLIC_CLIENT.SURNAME,
PUBLIC_CLIENT.ADDRESS_LINE_3
FROM initials, PUBLIC_CLIENT
WHERE
(((Fsoundex([initials]![Surname]))=FSoundex([PUBLIC_CLIENT]![Surname])));
the module this query calls is as follows;
Option Compare Database
Option Explicit
Public Function fSoundex(Word As String) As String
Dim strCode As String
Dim strChar As String
Dim lngWordLength As Long
Dim strLastCode As String
Dim i As Long
'Grabs the first letter
strCode = UCase(Mid$(Word, 1, 1))
strLastCode = GetSoundCodeNumber(strCode)
'Stores the word length
lngWordLength = Len(Word)
'Continues the code, starting at the second letter
For i = 2 To lngWordLength
If Mid$(Word, i, 1) <> " " Then ' If there is a space go to the next
character
strChar = GetSoundCodeNumber(UCase(Mid$(Word, i, 1)))
' If adjacent numbers are the same,
' only count one of them
If Len(strChar) > 0 And strLastCode <> strChar Then
strCode = strCode & strChar
End If
strLastCode = strChar
End If
Next
'Trim it down to a maximum of four characters...
fSoundex = Mid$(strCode, 1, 4)
'... but if it's less than four characters, pad
'it out with a bunch of zeros...
If Len(strCode) < 4 Then
fSoundex = fSoundex & String(4 - Len(strCode), "0"
End If
End Function
Private Function GetSoundCodeNumber(Character As String) As String
'Accepts a character and returns the
'appropriate number from the Soundex table
Select Case Character
Case "B", "F", "P", "V"
GetSoundCodeNumber = "1"
Case "C", "G", "J", "K", "Q", "S", "X", "Z"
GetSoundCodeNumber = "2"
Case "D", "T"
GetSoundCodeNumber = "3"
Case "L"
GetSoundCodeNumber = "4"
Case "M", "N"
GetSoundCodeNumber = "5"
Case "R"
GetSoundCodeNumber = "6"
End Select
End Function
any help appreciated
peter
I have a query which appears to run ok and I start getting a result but then
Access just stops responding, I 've tried running it o/nite when there is
little network traffic but the same. My sql for the query is as follows
SELECT initials.Surname, initials.Suburb, PUBLIC_CLIENT.SURNAME,
PUBLIC_CLIENT.ADDRESS_LINE_3
FROM initials, PUBLIC_CLIENT
WHERE
(((Fsoundex([initials]![Surname]))=FSoundex([PUBLIC_CLIENT]![Surname])));
the module this query calls is as follows;
Option Compare Database
Option Explicit
Public Function fSoundex(Word As String) As String
Dim strCode As String
Dim strChar As String
Dim lngWordLength As Long
Dim strLastCode As String
Dim i As Long
'Grabs the first letter
strCode = UCase(Mid$(Word, 1, 1))
strLastCode = GetSoundCodeNumber(strCode)
'Stores the word length
lngWordLength = Len(Word)
'Continues the code, starting at the second letter
For i = 2 To lngWordLength
If Mid$(Word, i, 1) <> " " Then ' If there is a space go to the next
character
strChar = GetSoundCodeNumber(UCase(Mid$(Word, i, 1)))
' If adjacent numbers are the same,
' only count one of them
If Len(strChar) > 0 And strLastCode <> strChar Then
strCode = strCode & strChar
End If
strLastCode = strChar
End If
Next
'Trim it down to a maximum of four characters...
fSoundex = Mid$(strCode, 1, 4)
'... but if it's less than four characters, pad
'it out with a bunch of zeros...
If Len(strCode) < 4 Then
fSoundex = fSoundex & String(4 - Len(strCode), "0"
End If
End Function
Private Function GetSoundCodeNumber(Character As String) As String
'Accepts a character and returns the
'appropriate number from the Soundex table
Select Case Character
Case "B", "F", "P", "V"
GetSoundCodeNumber = "1"
Case "C", "G", "J", "K", "Q", "S", "X", "Z"
GetSoundCodeNumber = "2"
Case "D", "T"
GetSoundCodeNumber = "3"
Case "L"
GetSoundCodeNumber = "4"
Case "M", "N"
GetSoundCodeNumber = "5"
Case "R"
GetSoundCodeNumber = "6"
End Select
End Function
any help appreciated
peter