Answered by:
MS Access 2010 TextBox.TextFormat

Question
-
Hy there!
I´m developing in MS Access 2010 and SQL SQL Server 2008 R2 and ADP Projects.
Does someone know a "workaround" for the circumstance that I cannot set the TextFormat on TextBoxes to "Rich Text"? Or is there an other way to get a TextBox formated with different styles (bold, italic, underlined, ...).
For a reason I don´t know the online-help says that it is not possible in projects. For me that seems not to be that big problem, but for microsoft engineers it is ... Maybe that changes in the next version.
Best regards from Vienna/Austria!
Martin
Martin Sachers
Saturday, February 11, 2012 4:20 PM
Answers
-
Hello Martin:
See this link:
http://office.microsoft.com/en-us/access-help/insert-or-add-a-rich-text-field-HA010014097.aspx
I have an application that uses a Rich Text box, and it is simply a matter of setting a textbox property as shown below (Access 2010). I am not sure why you can't see the TextFormat property??? The code below shows how I manually insert rich text HTML tags.
Here's a code snippet driven by a button that demonstrates setting a rich text box back to a standard format. The Me.Event_Description is a standard text box with the "RichText" format selected as shown above. Note that Access Memo fields have built-in Rich Text functionality. You can, however, do your own Rich Text formatting in non-memo fields, but it is a lot of code :)
Private Sub ChangeRichTextFont_Click() Dim strExtractedText As String Dim boolSkipTagContents As Boolean Dim intExtractCount As Integer Dim i As Integer Dim strRichTextHeader As String Dim strRichTextTrailer As String
strRichTextHeader = "<div><font face=Calibri size=1 color=black>"
strRichTextTrailer = "</font></div>"Me.Event_Description.TextFormat = acTextFormatPlain ' ******************************************************** ' If The Text Is Not in Rich Format, Do Usual Formatting ' ******************************************************** If Mid(Me.Event_Description, 1, 1) <> "<" Then With Me.Event_Description .SetFocus .SelStart = 0 .SelLength = 10 .FontName = "Calibri" .FontSize = 9 .SelStart = 0 End With Else ' ******************************************************** ' Remove All Tags From The Rich Text ' ******************************************************** For i = 1 To Len(Me.Event_Description) If Mid(Me.Event_Description, i, 1) = "<" Then boolSkipTagContents = True ElseIf Mid(Me.Event_Description, i, 1) = ">" Then boolSkipTagContents = False ElseIf Not boolSkipTagContents Then strExtractedText = strExtractedText & Mid(Me.Event_Description, i, 1) End If Next i ' ******************************************************** ' Build A Rich Text For The Default Calibri ' ******************************************************** Me.Event_Description.Value = strRichTextHeader & strExtractedText & strRichTextTrailer Me.Event_Description.TextFormat = acTextFormatHTMLRichText End If End Sub
Regards,
Rich Locus
Rich Locus, Logicwurks, LLC
- Edited by RichLocus Saturday, February 11, 2012 7:10 PM
- Marked as answer by Bruce Song Thursday, February 23, 2012 10:08 AM
Saturday, February 11, 2012 6:12 PM -
Bound controls on an Access form can ONLY be set to rich text if you using a memo column.
And in ADP, that means setting the column to type of text (in place of nvchar).
If you do this then should be able to use a bound text control, and you have use of the rich text formatting options from the ribbon.
You can ALSO set rich text for unbound controls.
You cannot set a text box control to rich text for regular bound columns in Access (even when not using SQL server).
So how this works for regular access and ADP is really quite much the same.
>For me that seems not to be that big problem, but for microsoft engineers it is
>Best regards from Vienna/Austria!Hum, what should I say here? Tell you what, I will give you a mulligan here, but I do tend to skip on past such questions.
Please keep in mind the vast majority of people here are giving answers to you represents an act of charity and goodwill on our parts.
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
- Marked as answer by Bruce Song Thursday, February 23, 2012 10:09 AM
- Unmarked as answer by Martin Sachers Thursday, February 23, 2012 1:23 PM
- Marked as answer by Martin Sachers Thursday, February 23, 2012 1:23 PM
Monday, February 13, 2012 5:42 AM
All replies
-
Hello Martin:
See this link:
http://office.microsoft.com/en-us/access-help/insert-or-add-a-rich-text-field-HA010014097.aspx
I have an application that uses a Rich Text box, and it is simply a matter of setting a textbox property as shown below (Access 2010). I am not sure why you can't see the TextFormat property??? The code below shows how I manually insert rich text HTML tags.
Here's a code snippet driven by a button that demonstrates setting a rich text box back to a standard format. The Me.Event_Description is a standard text box with the "RichText" format selected as shown above. Note that Access Memo fields have built-in Rich Text functionality. You can, however, do your own Rich Text formatting in non-memo fields, but it is a lot of code :)
Private Sub ChangeRichTextFont_Click() Dim strExtractedText As String Dim boolSkipTagContents As Boolean Dim intExtractCount As Integer Dim i As Integer Dim strRichTextHeader As String Dim strRichTextTrailer As String
strRichTextHeader = "<div><font face=Calibri size=1 color=black>"
strRichTextTrailer = "</font></div>"Me.Event_Description.TextFormat = acTextFormatPlain ' ******************************************************** ' If The Text Is Not in Rich Format, Do Usual Formatting ' ******************************************************** If Mid(Me.Event_Description, 1, 1) <> "<" Then With Me.Event_Description .SetFocus .SelStart = 0 .SelLength = 10 .FontName = "Calibri" .FontSize = 9 .SelStart = 0 End With Else ' ******************************************************** ' Remove All Tags From The Rich Text ' ******************************************************** For i = 1 To Len(Me.Event_Description) If Mid(Me.Event_Description, i, 1) = "<" Then boolSkipTagContents = True ElseIf Mid(Me.Event_Description, i, 1) = ">" Then boolSkipTagContents = False ElseIf Not boolSkipTagContents Then strExtractedText = strExtractedText & Mid(Me.Event_Description, i, 1) End If Next i ' ******************************************************** ' Build A Rich Text For The Default Calibri ' ******************************************************** Me.Event_Description.Value = strRichTextHeader & strExtractedText & strRichTextTrailer Me.Event_Description.TextFormat = acTextFormatHTMLRichText End If End Sub
Regards,
Rich Locus
Rich Locus, Logicwurks, LLC
- Edited by RichLocus Saturday, February 11, 2012 7:10 PM
- Marked as answer by Bruce Song Thursday, February 23, 2012 10:08 AM
Saturday, February 11, 2012 6:12 PM -
Bound controls on an Access form can ONLY be set to rich text if you using a memo column.
And in ADP, that means setting the column to type of text (in place of nvchar).
If you do this then should be able to use a bound text control, and you have use of the rich text formatting options from the ribbon.
You can ALSO set rich text for unbound controls.
You cannot set a text box control to rich text for regular bound columns in Access (even when not using SQL server).
So how this works for regular access and ADP is really quite much the same.
>For me that seems not to be that big problem, but for microsoft engineers it is
>Best regards from Vienna/Austria!Hum, what should I say here? Tell you what, I will give you a mulligan here, but I do tend to skip on past such questions.
Please keep in mind the vast majority of people here are giving answers to you represents an act of charity and goodwill on our parts.
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
- Marked as answer by Bruce Song Thursday, February 23, 2012 10:09 AM
- Unmarked as answer by Martin Sachers Thursday, February 23, 2012 1:23 PM
- Marked as answer by Martin Sachers Thursday, February 23, 2012 1:23 PM
Monday, February 13, 2012 5:42 AM -
Greetings all, I'm looking for the most straight forward solution (which could be data formatting, coding, both or none).
I am a newbie to Access VBA & web programming. I too am using Access 2010 using an ADP file w/ SQL 2008r2 backend. I also have a web front-end that views parts and pieces of the SQL data (more on that in a bit).
Background: the data in question resides in the SQL server in a varchar(2000) field. The ADP form in question has a "Text Box" object holding the data whose properties are set as: "Text Format" field = "Plain Text" (One record is shown below as an example)...
START SAMPLE 1 - "Plain Text" format
<b>PROJECT SUPPORT TEAM CONTACT INFO</b>
Support Queue: <b>(xxx) xxx-xxxx PIN xxxx</b>
Press option <b>1</b> (for the xxxxxxxxxx project)
Then press:
<b>1</b> To <b>check-in</b> for a site visit
<b>2</b> To report the status of <b>inventory or installation related tasks</b>
<b>3</b> To report or provide an update on an <b>issue</b> that has occurred since check-in
<b>4</b> If you are <b>checking out</b> from a site visit
<b>5</b> For issues related to your <b>Vendor account</b> after initial check-in
<b>E-Mail:</b> support@domain.com
ENDWhen I set the properties "Text Format" field = "Rich Text" I get the following text - (No carriage returns). Okay remember that web front-end? Skip down...
START SAMPLE 2 - "Rich Text" format
PROJECT SUPPORT TEAM CONTACT INFO
Support Queue: (xxx) xxx-xxxx PIN xxxx Press option 1 (for the xxxxxxxxxx project) Then press: 1 To check-in for a site visit 2 To report the status of inventory or installation related tasks 3 To report or provide an update on an issue that has occurred since check-in 4 If you are checking out from a site visit 5 For issues related to your Vendor account after initial check-in E-Mail: support@domain.com
ENDFor the final part of my situation... when viewed on our website the information appears correctly formatted...
START SAMPLE 3 - "Web" format
PROJECT SUPPORT TEAM CONTACT INFO
Support Queue: (xxx) xxx-xxxx PIN xxxx
Press option 1 (for the xxxxxxxxxx project)
Then press:
1 To check-in for a site visit
2 To report the status of inventory or installation related tasks
3 To report or provide an update on an issue that has occurred since check-in
4 If you are checking out from a site visit
5 For issues related to your Vendor account after initial check-inE-Mail: euc-rtd@wellsfargo.com
END
Is there anything I can do to allow the use of the "Rich Text" "Text Format" to manage the format of this data? Do I need to reformat the data or something else? (Related side note: we are planning to rewrite the parts still in the ADP frontend into a web interface, but I am looking for an interim solution.)
Many thanks for your insights in advance!
Tony Bromirski,
Eagle River, Alaska
Thursday, May 10, 2012 11:22 PM