I have a report with a rich text field ([testg]) showing groups of tests e.g. "cbc, ethanol, phos". I want to change the font color of test items if they are stored in a table (tblHighlight). To do this, I am trying to create a function that loops through the test items on the report and if the test item is found in tblHighlight, replaces the test item in red font in the report. I am having trouble with the syntax of the line of code in "blue" see below:
On the format event of the report, I have:
Public Function WHlight(TestG As String)
Dim dbs As Database
Dim rs As Recordset
Dim Idx As Long
Set dbs = CurrentDb
Set rs = dbs.OpenRecordset("tblHighlight", dbOpenDynaset)
rs.MoveLast
rs.MoveFirst
Idx = 1
For Idx = 1 To rs.RecordCount
'Debug.Print rs!htest
If InStr(TestG, rs!htest) > 0 Then
TestG = Replace(TestG, rs!htest, "<font color=""red"">rs!htest</font>")
WHlight = TestG
End If
rs.MoveNext
Next Idx
rs.Close
Set dbs = Nothing
End Function
thanks for your help in advance