Formatting in RTF Text Box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BikeToWork
    New Member
    • Jan 2012
    • 124

    Formatting in RTF Text Box

    I am using Access 2007 and have a large textbox whose TextFormat is set as RTF and is bound to a memo field. There are several command buttons which automatically insert email text into the textbox, such as Header, Signature, etc. If the TextFormat for the textbox is plain text, the carriage returns and line feeds are all inserted according to what is in the code. However, if I switch the textbox to RTF TextFormat, it ignores the hard returns in the code and just inserts its own hard returns to wrap the text. Does anyone know of a workaround for this?
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    There is a 'long' work-a-round. Once Data is entered into the Bound Rich Text Box, you can physically insert Hard Carriage Returns (CTRL+ENTER) wherever appropriate, and the Formatting will persist. Hopefully, you or asomeone else, can come up with a 'shorter' work-a-round (LOL).

    Comment

    • BikeToWork
      New Member
      • Jan 2012
      • 124

      #3
      Thanks, ADezii. I was looking for a more automated solution, if there is one. Why does the RTF text box just ignore the VBCRLF's in the code, whereas the plain text text box does not?

      Comment

      • Luk3r
        Contributor
        • Jan 2014
        • 300

        #4
        This may be a silly question on my part, especially because I don't know a ton about VBA, but are you able to set a multiline property for the RTB? In VB.NET, if a textbox or RTB has the multiline property disabled it will not accept carriage returns.

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          I think that I have figured it out for you BikeToWork. The MEMO Field for a Bound Rich Text Box (txtTest in this case) appears to utilize HTML Encoding to properly Format the Rich Text contents. You need to use the HTML equivalent of a CR/LF in order to produce the same effect. Case in point:
          Code:
          strTest = "Test<br>String<br>for<br>BikeToWork"
          
          Me![txtTest] = strTest
          produces & preserves
          Code:
          Test
          String
          for
          BikeToWork
          within the Bound Rich Text Box.

          Comment

          • BikeToWork
            New Member
            • Jan 2012
            • 124

            #6
            Thanks again, ADezii. You are correct about the html code for the rtf control. Access puts it in automatically when the user puts in a hard return or bolds some text, etc.

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #7
              You are quite welcome, so all works well?

              Comment

              • BikeToWork
                New Member
                • Jan 2012
                • 124

                #8
                ADezii, unfortunately it won't work with my program. If I use <br> or <div> for new lines in the code, it will appear without the code tags in the text box but when I use the SendObject command to send the email, it shows up with all the html code tags, even if I specify acFormatHTML and select HTML format in Outlook. It was a good learning experience, though.

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32653

                  #9
                  I believe the .Value has all the codes but if you want the text without them then .Text has that.

                  Comment

                  Working...