Insert or add a rich text field
In Microsoft Office Access 2007, you can store rich, formatted text in a database. You do this by using a memo field and setting the field's TextFormat property (new in Office Access 2007) to RichText. You can apply formatting to all or part of the contents of the field by editing the field through a bound control in a form, or when the field is displayed in a datasheet. You can also apply formatting to all of a field when viewing a report in Layout View (new in Office Access 2007).
This article explains how to insert or change a memo field that uses rich text, and how to format text by using rich text formatting options.
In this article
What is rich text?
Rich text is text that is formatted with common formatting options, such as bold and italics, that are unavailable with plain text. You format your data by using the formatting tools common to 2007 Microsoft Office system programs, such as Microsoft Office Word 2007 and Microsoft Office PowerPoint 2007. Behind the scenes, Office Access 2007 applies Hypertext Markup Language (HTML) formatting code to your data. Access uses HTML because it provides a greater degree of compatibility with rich-text fields stored in Windows SharePoint Services 3.0 lists.
The following table lists the rich text formatting options supported by Office Access 2007:
Icon | Option | Description |
| Font name | Selects a different typeface. |
| Font size | Selects a font size. |
| Bold | Makes the selected text bold. If the text is already bold, removes the bold. |
| Italic | Makes the selected text italic. If the text is already italic, removes the italic. |
| Underline | Makes the text underlined. If the text is already underlined, removes the underline. |
| Align left | Aligns the text against the left margin. |
| Center | Centers the text within the margin. |
| Align right | Aligns the text against the right margin. |
| Numbering | Begins numbering paragraphs. The number appears prior to each paragraph. |
| Bullets | Begins placing a bullet before each paragraph. |
| Font color | Selects a font foreground color. |
| Text highlight color | Makes text look like it was marked with a highlighter pen. |
| Decrease indent | Decreases the paragraph indentation. |
| Increase indent | Increases the paragraph indentation. |
| Left-to-right | Fills control from left to right. |
| Right-to-left | Fills control from right to left. |
Office Access 2007 stores rich text by using the Memo data type. This is the only data type in Access that has built-in support for rich text. To create a field for storing rich text, you create a memo field and then set that field's TextFormat property to RichText.
Introducing the TextFormat property
Most controls, fields, and objects in Access have an associated series of properties. A property is a named value that defines some characteristic of the object — such as its position, size, and whether or not it is visible. The TextFormat property holds the setting that determines whether the text is treated as rich text or plain text. The two possible values are:
TextFormat property | Description |
RichText | The text is displayed as rich text and is stored and interpreted as rich HTML markup. |
PlainText | The text is displayed as plain text and is interpreted as plain text. |
You set the TextFormat property for the memo field in table Design view. The value you set there is inherited by any text box you create to display the data in the memo field. The value is inherited only when you create the control, however. You can subsequently change the value by using the property sheet for the text box.
Create a rich text field
You store rich text in a field that uses the Memo data type. This is the only data type that has built-in support for displaying and storing rich text. To create a field that can store rich text, you first create a memo field and then set the TextFormat property of the memo field to RichText.
Create a memo field to store rich text
-
Click the Microsoft Office Button , and then click Open.
-
In the Open dialog box, open the database to which you want to add the field.
-
In the Navigation Pane, right-click the table to which you want to add the rich text field, and then click Design View.
-
In the table design grid, locate the first empty row. Then, in the Field Name column, type a field name.
-
In the Data Type column, select Memo.
-
Under Field Properties, click the General tab.
-
Click inside theText Format box and select Rich Text.
-
To save the table, click Save . on the Quick Access Toolbar.
After you create the memo field, you can enter and format rich text in Datasheet view or in Form view. For information about formatting rich text, see the section Apply formatting options to text, later in this article.
Change an existing plain text field to a rich text field
If you have an existing memo field that you would like to change so that it can store rich text, you can change the TextFormat property for that field from PlainText to RichText. If you have an existing text field that you want to change so that it can store rich text, you must first change the data type of the field from Text to Memo.
Change an existing memo field to store rich text
-
Start Office Access 2007.
-
Click the Microsoft Office Button , and then click Open.
-
In the Open dialog box, open the database that contains the field.
-
In the Navigation Pane, right-click the table that contains the field, and then click Design View.
-
In the table design grid, click the memo field that you want to change to rich text.
-
Under Field Properties, click the General tab.
-
Click inside the Text Format box and select Rich Text.
-
To save the table, click Save.
Change an existing text field so that it can store rich text
-
Click the Microsoft Office Button , and then click Open.
-
In the Open dialog box, open the database that contains the field.
-
In the Navigation Pane, right-click the table that contains the field, and then click Design View.
-
In the table design grid, click the text field that you want to change to rich text.
-
Under Data Type, change Text to Memo.
-
Under Field Properties, click the General tab.
-
Click inside the Text Format box and select Rich Text.
-
To save the table, click Save.
After you have stored rich text in a memo field, you can display it in a form or report by using a text box control. The text box control has a TextFormat property that inherits its initial value from the TextFormat property of the memo field. However, you can change the TextFormat property on the text box control.
Apply formatting options to text
When you edit a rich text field, whether in Datasheet view or in Form view, you can apply formatting options by using the commands on the Mini toolbar or in the Font and Font Alignment groups on the Home tab. First, you select the text that you want to format, then you apply the formatting options.
When you use the mouse to select text in a memo field that supports rich text, the Mini toolbar appears after you complete your selection and release the left mouse button. The Mini toolbar includes buttons for the most commonly used formatting options.
Suppose you want to add emphasis to some text by applying bold formatting to make it darker and heavier.
Apply formatting using the Mini toolbar
-
Click and drag to select the text you want to format.
The Mini toolbar appears.
-
Position your mouse pointer over the Mini toolbar to make it more visible, and click Bold .
When the Mini toolbar appears, it reflects the formatting characteristics of the text you have selected. For example, if the text is already bold, the Bold button on the toolbar will appear highlighted.
You can also apply formatting options from the Home tab on the Ribbon, part of the Microsoft Office Fluent user interface. Let's suppose you want to apply the Italic formatting option.
Apply formatting by using the Office Fluent Ribbon
-
Click and drag to select the text you want to format.
-
On the Home tab, in the Font group, click Italic .
Tip: To quickly select a word, place the pointer on the word and double-click. To select the entire paragraph, click three times.
Change a rich text field to a plain text field
You can change a rich text field to plain text and remove all formatting by changing the field's TextFormat property to Plain Text. When you change a field from rich text to plain text, Office Access 2007 prompts you with a warning that all formatting will be removed. After you have applied the change to plain text and the table has been saved, you cannot undo the change.
Change a rich text field to plain text
-
Start Office Access 2007.
-
Click the Microsoft Office Button , and then click Open.
-
In the Open dialog box, select and open the database that contains the field.
-
In the Navigation Pane, right-click the table that contains the field, then click Design View.
-
In the table design grid, click the Memo field that you want to change to rich text.
-
Under Field Properties, click the General tab.
-
Click in the TextFormat box and select Plain Text.
-
To save the table, click Save.
What to do when the TextFormat property gets out of sync
For rich text support to work correctly, you must set the TextFormat property on both the memo field and any text box control that displays the memo field. Typically, these TextFormat properties should be the same. For example, the TextFormat property for both the field and the control should be set to RichText if you want them to support rich formatted text. If you don't want rich text, the property for each should be set to PlainText. If the TextFormat property on the memo field is set to RichText and the TextFormat property on the text box is set to PlainText, you'll see the full rich text HTML in the text box in Form view and in Datasheet view.
For more information
-
For more information about formatting data, see Format data in rows and columns.
No comments:
Post a Comment