There is a sample database on the linked page I recommended. Reviw the article and the associated database.
Here is the code to find and highlight the desired text.
I have modified code to bold and color the found text RED
Code:
Private Sub txtSearchText_AfterUpdate()
On Error GoTo Err_Handler
'Purpose: Filter, and highlight matches in txtSearchDisplay.
Dim strField As String 'The field to search
Dim strSearchValue As String 'The value to find
Dim strControlSource As String 'ControlSource for displaying match.
Const strcWildcard = "*" 'Some other back ends use %
'HTML tags for highlighting matches. Could be just "<b>" and "</b>".
'Using Bold and RED
Const strcTagStart = "<b><font color=""""red"""">" 'jed Feb 2025<----modified line
Const strcTagEnd = "</font></b>"
'Save any edits.
If Me.Dirty Then
Me.Dirty = False
End If
'Apply a filter only if user chose a field and a value.
If IsNull(Me.cboField) Or IsNull(Me.txtSearchText) Then
If Me.FilterOn Then
Me.FilterOn = False
End If
Call ShowHide(Me.txtSearchDisplay, False)
Else
strField = "[" & Me.cboField & "]" 'Cope with spaces in field name.
strSearchValue = Me.txtSearchText
'Apply the filter
Me.Filter = strField & " Like """ & strcWildcard & strSearchValue & strcWildcard & """"
Me.FilterOn = True
'Control Source for the text box to display matches.
strControlSource = "=IIf(" & strField & " Is Null, Null, " & _
"Replace(" & strField & ", """ & strSearchValue & """, """ & _
strcTagStart & strSearchValue & strcTagEnd & """))"
With Me.txtSearchDisplay
.ControlSource = strControlSource
.Visible = True
End With
End If
Exit_Handler:
Exit Sub
Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & "txtSearchText_AfterUpdate")
Resume Exit_Handler
End Sub