Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 684
  • Last Modified:

Search Button for Memo Field, overflow error


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)
End If
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"
End If

End Sub

Open in new window

  • 2
  • 2
1 Solution
Jeffrey CoachmanMIS LiasonCommented:
pdvsaProject financeAuthor Commented:
That is pretty nice looking form.  
It did say:
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
Jeffrey CoachmanMIS LiasonCommented:
Without a sample, I am a bit lost.

<i need a "next" button to find the next occurrence.>
In a broad sense, you would load a table with all your "search" terms.
Then create a recordset from this table
Then loop this table each time you clicked you "Next" button
'Your Highlight Code

Make sense?

But again, it seems we need to address the error in your original question first...
For that, a sample would be very useful.
(you know the drill...)
pdvsaProject financeAuthor Commented:
I will have to revisit again...thanks.  It is not that important at the moment.

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now