The line that is causing the problem is:
Code:
If InStr(1, SearchString, "seed") > 0 Then
The syntax for the InStr() function is InStr([start, ]string1, string2)
where
string1 - Required. String expression being searched.
string2 - Required. String expression sought.
If you enter "seed" in "SearchString" (string1) and you are searching for "seed" (string2), what do you thing the result will be?? Yep, the result will always be TRUE.
If you enter "stem" in "SearchString"(string1) and you are searching for "seed" (string2), what do you thing the result will be?? Yep, the result will always be TRUE.
So "SearchString" is what you are searching for (ie string2) and "rsCat!strProdCat" is what string is being searched (ie string1).
I rewrote your function
Code:
Private Sub cmdAssignCat_Click()
Dim curdb As DAO.Database
Dim rsCat As DAO.Recordset
Dim SearchString As String
Dim NewValue As String
Set curdb = CurrentDb
Set rsCat = curdb.OpenRecordset("tblProduct")
SearchString = Me.strProductName
Do Until rsCat.EOF
If InStr(1, rsCat!strProdCat, SearchString) > 0 Then
NewValue = "Seeds"
Else
NewValue = "Misc"
End If
rsCat.Edit
rsCat!strProdCat = NewValue
rsCat.Update
rsCat.MoveNext
Loop
'clean up
rsCat.Close
Set rsCat = Nothing
Set curdb = Nothing
End Sub
The BLUE is what I added/changed......