Public Function wordInField(strTerm As String, strSearchString As String) As Boolean
Dim intPosition As Integer
Dim strNextOrPreviousCharacter As String
intPosition = InStr(1, strTerm, strSearchString)
Select Case intPosition
Case 0 'Word was not found in search string
wordInField = False
Case 1 'Word found at the beginning of the search string
strNextOrPreviousCharacter = Mid(strSearchString, Len(strTerm) + 1, 1) 'Look at character immediately following strTerm
If strNextOrPreviousCharacter = " " Or strNextOrPreviousCharacter = "," Then
wordInField = True
Else
wordInField = False
End If
Case Else
strNextOrPreviousCharacter = Mid(strSearchString, intPosition - 1, 1) 'Look at character immediately preceding strTerm
If strNextOrPreviousCharacter = " " Then
strNextOrPreviousCharacter = Mid(strSearchString, intPosition + Len(strTerm), 1) 'Look at character immediately following strTerm
If strNextOrPreviousCharacter = " " Or strNextOrPreviousCharacter = "," Then
wordInField = True
Else
wordInField = False
End If
Else 'found term is not a standalone word
wordInField = False
End If
End Select
End Function