pdvsa
asked on
Search Button for Memo Field, overflow error
Experts,
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:
https://www.experts-exchange.com/questions/26481808/Find-button-for-memofield-txt-box.html
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.
thanks..
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:
https://www.experts-exchange.com/questions/26481808/Find-button-for-memofield-txt-box.html
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.
thanks..
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)
End If
If j <> 0 Then
Me.txtNotes.SetFocus
Me.txtNotes.SelStart = j - 1
Me.txtNotes.SelLength = Len(sWord)
Else
MsgBox "Word " & Chr(34) & sWord & Chr(34) & " not found!", vbQuestion, "WORD SEARCH"
End If
End Sub
ASKER
That is pretty nice looking form.
It did say:
Limitations
The sample database is concept-only. You will need to develop it further to use it with:
"Memo fields where rich text is stored (tags may clash);"
The field i am searching is Memo ppty.
It seems as though it highlights but i dont think that will help me as i need the cursor to go directly to the search term and i need a "next" button to find the next occurrence.
What do you think now? Thank you
It did say:
Limitations
The sample database is concept-only. You will need to develop it further to use it with:
"Memo fields where rich text is stored (tags may clash);"
The field i am searching is Memo ppty.
It seems as though it highlights but i dont think that will help me as i need the cursor to go directly to the search term and i need a "next" button to find the next occurrence.
What do you think now? Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I will have to revisit again...thanks. It is not that important at the moment.
http://allenbrowne.com/AppSearchHighlight.html