Change text colour of part of text within text box on report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • laurajchambers
    New Member
    • Aug 2014
    • 17

    Change text colour of part of text within text box on report

    Hi

    I have a text box on a report which is formatted to Rich Text.

    The text box has a large amount of text and I would like to format some words to a different text colour, e.g. Red. I've been trying to do it in HTML but nothing is working. Maybe I can achieve this in VBA? However I was hoping there would be a simple way to do it within the text box - ?

    Can anybody help please?
    Thanks
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #2
    Hi Laura.

    I'm trying to look into this for you but I can find nowhere to specify that a TextBox be RTF. Can you explain how you did that for me please.

    BTW I'm using 2010. Which version are you using?

    PS. I just found the TextBox property called .TextFormat (Text Format).
    Last edited by NeoPa; Aug 25 '15, 10:50 PM. Reason: Added PS.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32656

      #3
      Hi Laura.

      It seems if you want to change every occurrence of the three letters "red" to show in red text then you would use <font color=red>red</font>.

      Some VBA to do this for you would be something like :
      Code:
      Me.{ControlName}.Value = Replace(Me.{ControlName}.Value _
                                     , "red", "<font color=red>red</font>")
      NB. Careful, as this would also colour the last part of "Coloured" ;-)

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32656

        #4
        BTW. You do know that a special toolbar called the Mini-Toolbar will always pop up when you select text within such a TextBox which will allow you to make the changes manually don't you?

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32656

          #5
          In case it helps, this office.com link may prove helpful :
          Insert or add a rich text field.

          I was also able to discover a list of the HTML tags that are supported in MS RTF fields :
          Code:
          <div>,<font>,<strong>,<em>,<u>,<ol>,<ul>,<li>,<blockquote>
          The first two tags support extra options as follows :
          Code:
          <font>: face, size, color, style(with BACKGROUND-COLOR only)    
          <div>: align, dir
          Hopefully this will give you all you need to know, or at least give you a good head-start.

          Comment

          • laurajchambers
            New Member
            • Aug 2014
            • 17

            #6
            Thanks for your replies, NeoPa.

            I'm using Access 2007. To format the text box to Rich Text I went into the Property Sheet and changed 'Text Format' to Rich Text on the 'All' tab.

            Unfortunately I don't want every occurrence of the word to be red font, so I don't think <font color=red>red</font> will achieve what I need it to?

            I have tried the toolbar but it appears to change the font colour of the entire text box to red, even though I highlighted the word I wanted to change.

            Thank you for the tag information. Do you know how I would include this within the text box please? I've tried to add it to the string, but when I then run the report it asks me for the parameter as it doesn't recognise it.

            E.G.

            =[Forename] & " " & [Surname] & " (" & [ID] & "). " & [Forename] & " requires ............... ."

            How could I make the first Forename red, but not the second occurence?

            Thank you for all of your assistance.

            Comment

            • laurajchambers
              New Member
              • Aug 2014
              • 17

              #7
              Hi again, NeoPa

              I managed to get your tag working. <font color=red>WORD</font>

              The previous time I enclosed it within '&' as I thought it would need connectors. But I just removed those and it works perfectly.

              Thanks for pointing me in the right direction - much appreciated.

              Laura

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32656

                #8
                My pleasure Laura :-)

                Comment

                Working...