You need to include the asterisk wildcard character. In query design view:
Like "*manager*" And Not Like "*nurse*"
in the criteria row of the column should do it. This does assume that
neither 'manager' nor 'nurse' will be substrings of other words within the
column. To find them only as complete 'words' the following function can be
used:
Public Function FindWord(varFindIn As Variant, varWord As Variant) As Boolean
Const PUNCLIST = " .,?!:;(){}[]"
Dim intPos As Integer
FindWord = False
If Not IsNull(varFindIn) And Not IsNull(varWord) Then
intPos = InStr(varFindIn, varWord)
' loop until no instances of sought substring found
Do While intPos > 0
' is it at start of string
If intPos = 1 Then
' is it whole string?
If Len(varFindIn) = Len(varWord) Then
FindWord = True
Exit Function
' is it followed by a space or punctuation mark?
ElseIf InStr(PUNCLIST, Mid(varFindIn, intPos + Len(varWord),
1)) > 0 Then
FindWord = True
Exit Function
End If
Else
' is it precedeed by a space or punctuation mark?
If InStr(PUNCLIST, Mid(varFindIn, intPos - 1, 1)) > 0 Then
' is it at end of string or followed by a space or
punctuation mark?
If InStr(PUNCLIST, Mid(varFindIn, intPos + Len(varWord),
1)) > 0 Then
FindWord = True
Exit Function
End If
End If
End If
' remove characters up to end of first instance
' of sought substring before looping
varFindIn = Mid(varFindIn, intPos + 1)
intPos = InStr(varFindIn, varWord)
Loop
End If
End Function
Add it to a standard module and call it in the query like so, in SQL view:
WHERE FindWord([YourFieldName],"manager")
AND NOT FindWord([YourFieldName],"nurse")
Or in design view put the following in the 'field' row of a blank column:
FindWord([YourFieldName],"manager")
Uncheck the 'show' checkbox, and in its first 'criteria' row put:
True
Put the following in the 'field' row of a another blank column:
FindWord([YourFieldName],"nurse")
Uncheck the 'show' checkbox, and in its first 'criteria' row put:
False
Ken Sheridan
Stafford, England
I have been successful in selecting records in a table that bear the word,
"manager" in one field.
I also need to exclude records in the same table that bear the word,
"nurse", in the same field.
Nothing like, <Like "manager" AND NOT Like "Nurse"> has worked, and clearly
I don't know the syntax for this selection criterion.
If this is clear, could somebody make a suggestion?
Thanks.
Don.
--
Message posted via AccessMonster.com
.