If you add the following function to a standard module:
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)
If intPos > 0 Then
' 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
End If
End If
End Function
(Watch out for single lines in the above which might have been split over
two lines by your newsreader)
Then you should be able to call it in a query like so:
WHERE FindWord(Skills.Skills, Model.Model);
The function handles the points John made about preceding and trailing
blanks, characters at the beginning and the end of the memo field, etc, but
the more important problem is that you are using the memo field as data
structure, which means the Skills table is not normalized to First Normal
Form.
Ken Sheridan
Stafford, England
Dave said:
I want to look for specific infor mation in one table and see if it exists in
another table
Table A
Model
1
2
3
Table B
Skills - Memo Field
1 2 4 5 >> Model 1 2 from above would match
3 4 5 >> Model 3 from above would match
1 5 >> Model 1 from above would match
5 >> No matches
I tried
SELECT Model.Model, Skills.Skills INTO Audit
FROM Model, Skills
WHERE (((Model.Model) Like "*" & ([Skills].[Skills]) & "*"));
AND
WHERE (((Model.[Model]) In ([Skills].[Skills])));
can you get me started