Hi,
I have a search box and I am trying to have the results highlighted.
Example if user enters "photons quantum energy" in the search box, rows with the words "photons","quantum" or "energy" in the "ProposalAbstract" column will be filtered and any of the 3 words will be highlighted.
So far I have managed to write the code for the search filtering only. Can someone help me with the code to highlight the search results. Thank you very much. By the way I have just started learning Access with no IT background.
------
Option Compare Database
Private Sub Command13_Click()
Dim Keywords As String
Dim fieldToSearch As String
Dim Criteria As String
Dim SQL As String
' remove leading and trailing spaces, if any, from user input.
Keywords = Trim(Me.Find)
' specify which field to search.
fieldToSearch = "[ProposalAbstract]"
' create criteria based on input.
Do While InStr(Keywords, " ") > 0
Criteria = Criteria & fieldToSearch & " Like ""*" & Left(Keywords, InStr(Keywords, " ") - 1) & "*"" or "
Keywords = Mid(Keywords, InStr(Keywords, " ") + 1)
Loop
Criteria = Criteria & fieldToSearch & " Like ""*" & Keywords & "*"""
Me.Filter = Criteria
Me.FilterOn = True
Me.Requery
'Me.Find.SetFocus
'Me.FilterOn = False
'Me.Filter = "[ProposalAbstract] Like '*" & Find & "*'"
'Me.FilterOn = True
'Me.Requery
End Sub
Private Sub Command14_Click()
DoCmd.ShowAllRecords
Me.Find.SetFocus
Me.Find = ""
End Sub
Private Sub Form_Load()
Me.Find.SetFocus
End Sub