I get this overflow error sometimes in the code below.
The search term is actually contained in the memo field but it returns the error (attached).
this is a follow up to a question:
How can I get rid of the error? (note that the search term is in the memo field but still gives error...sometimes though).
Maybe someone can give me different code options for this search in a memo field that is rich text. It doesnt seem to be very predictable and doesnt pinpoint the item found. It si usually way off and highlights another term and not the search term. If I change the setting from rich text to plain text then it works fine and search term is pinpointed exactly.
Private Sub cmdFindWord_Click()
sWord = InputBox("Type word to find")
If Len(Trim(sWord)) > 0 Then
sNote = Me.txtNotes
'j = InStr(sNote, sWord)
j = InStr(PlainText(sNote), sWord)
If j <> 0 Then
Me.txtNotes.SelStart = j - 1
Me.txtNotes.SelLength = Len(sWord)
MsgBox "Word " & Chr(34) & sWord & Chr(34) & " not found!", vbQuestion, "WORD SEARCH"