Results 1 to 1 of 1
  1. #1
    silverspr is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    19

    Thumbs up Set format of rich text field

    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
    Last edited by silverspr; 03-28-2011 at 01:30 PM.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Edit Buttons for a Rich Text Box on Form
    By trb5016 in forum Forms
    Replies: 2
    Last Post: 10-13-2010, 12:28 PM
  2. Rich Text Boxes (Word OLE vs ?)
    By nichojo in forum Programming
    Replies: 1
    Last Post: 08-30-2010, 12:11 PM
  3. Need help with Memo field text format
    By sprovoyeur in forum Access
    Replies: 1
    Last Post: 05-14-2010, 08:03 AM
  4. Field switching from Number format to Text
    By COforlife in forum Queries
    Replies: 1
    Last Post: 11-10-2009, 03:23 PM
  5. Macro to set rich text attributes?
    By EER in forum Programming
    Replies: 0
    Last Post: 03-04-2009, 09:25 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums