One more quick follow-up, in order for the highlight formula to work, I have to set the property Form – Data – Allow Additions to “Yes” (otherwise, the reference error appears (run-time 2185) when searching for an item). The main problem with this is that “!Type#” appears in the field that contains the formula in the “new record” at the bottom.
I thought this might be because of the null value in the “new record”, so I inserted the Nz formula. I also tried adding default values for the new records, but didn’t have any luck.
Here is the current formula in the control source:
Code:
=IIf(IsNull([txtSearch]),[txtFoodItem],HighTest([txtFoodItem],[txtSearch])
And the Highest function is:
Code:
Function HighTest(strText As String, strSearch As String)
Dim strTemp As String
Dim strPhrase As String
Const strcTagStart = "<font color=red>"
Const strcTagEnd = "</font>"
strTemp = PlainText(strText) 'to remove any formatting
strPhrase = Mid(strTemp, InStr(strTemp, strSearch), Len(strSearch))
strTemp = Replace(strTemp, strPhrase, strcTagStart & strPhrase & strcTagEnd, , 1)
strText = Replace(strTemp, vbCrLf, "<br>")
HighTest = strText
End Function
Any thoughts? Thanks.