I am really thankful for the incredibly quick and valuable responses I have had to my post. You pointed me in the right direction to unravel the mistake I had made. This is clearly the forum to watch and learn from.
I thought it might be valuable to document the consequences of making changes to the Text Format property on the Long Text field and the Text Box form field. There are a few combinations with some to me unexpected consequences.
I created a few Test Cases to explore the Text Format settings. I did this in two steps:
- Table and Datasheet
In essence, this is just the table by itself. I use the datasheet to see the impact of my Text Format changes.
- Table and Form
In this section, I put the Table and the Form together. The results are documented below.
Table and Datasheet
There are two levels of formatting with a Datasheet. In the MS Access top menu bar there are a number of formatting commands we typically associate with rich text, such as bold, colour, text size, etc. When you select these formatting commands, they will apply to the
whole Datasheet. This is
not the field-level formatting that we are looking at with the following test cases. We are looking at formatting capabilities specific to a Text Box field. This means that if we have a text with multiple sentences, Rich Text means we should be able to format the individual words and sentences.
TABLE | TABLE (cont.) | OBSERVATIONS |
Field Type | Text Format property of table field | |
Short Text | This property does not exist for this field type. | As expected, I can only enter plain text |
Long Text | Plain Text (which is the default) | The only formatting commands I can access are those in the top menu bar which are datasheet-wide formatting commands as explained above this table. |
| Rich Text | When I switch the Text Format property to Rich Text, MS Access gives me a warning that the text will be HTML-encoded.
When I select a portion of the text, a formatting bar pops up. Any command I choose will only apply to the selected portion of the text. The remaining text stays as is, as do all the other fields and records.
This is the expected behaviour. |
| Plain Text | When I switch the Text Format property to Plain Text, MS Access gives me a warning that all formatting commands will be removed.
Indeed, in Datasheet view, all the previously formatted rich text is now converted back to plain text. There are no HTML commands visible. |
| Rich Text | If I now switch back to Rich Text again, the previously formatted rich text does not re-appear. Therefore, switching from Rich to Plain Text will indeed permanently remove all the formatting commands. |
Table and Form
The setup is one Table with one field, either Short or Long Text, and one Form with one Text Box. Except for the first four Test Cases, the Text Box will be bound to the field in the table.
I could create a form with multiple Text Box fields, each illustrating one of the Test cases below. However, I am particularly interested in what happens when I change properties. This is what is displayed in the table below.
The Text Format property for the Text Box field can be found in Design View on the Property Sheet (Data tab) for the Text Box field.
TABLE | TABLE (cont.) | FORM | OBSERVATIONS |
Field Type | Text Format property of table field | Text Format property of entry field | |
--- | --- | Plain Text | As expected, all text entered is just in plain text |
| | Rich Text
(Unbound Text Box) | The moment I select all or a portion of the text, a Formatting bar pops up. Any of these commands will apply those formatting commands to the text selected.
Expected behaviour. |
| | Plain Text
(Unbound Text Box) | Keeping the richly formatted text in the entry field, I will now switch the Text Format property to Plain Text.
All text is indeed converted to plain text but all the HTML-encoded tags are still there and visible. |
| | Rich Text
(Unbound Text Box) | Without changing the content of the Text Box, I now switch the Text Format property back to Rich Text again.
All the HTML tags are re-applied and the text looks like it did before, i.e. richly formatted. |
| | | |
In all Test Cases below the Text Box is bound to the field in the Table | | | |
Short Text | This property does not exist for this field type. | Can only be Plain Text | The Text Format property of the Text Box shows both Plain and Rich Text options but, the Rich Text option gives an error that it is not valid.
The text is plain text, as expected. |
Long Text | Plain Text | Plain Text | Text entered into the Text Box is displayed, as expected, like plain text. |
| | Rich Text | When I try to switch the Text Format property of the Text Box, MS Access gives a warning that some of the data might not be displayed correctly but it accepts the new setting.
The Text Box accepts the rich formatting commands and displays the text correctly. However, the table is now not set for rich text and captures the data as plain text. All the HTML tags are converted to plain text.
If I look at the table with a Datasheet, I can see all the HTML tags in the richly formatted text. |
| | Plain Text | If I now switch the Text Format back to Plain Text, you'll see all the previously entered data including all the HTML tags. |
| | | |
Long Text | Rich Text | Plain Text | Plain text is displayed and captured in the table as plain text. Expected behaviour.
However, the previously rich-formatted text is converted into plain text. It is a literal translation of all the HTML reserved symbols like '<' with '<' and '>' with '>'. So '<div>' becomes '<div>' Anyway, not exactly what you want. |
Long Text | Rich Text | Rich | All plain text is displayed and captured as plain text.
All richly-formatted text that was entered before is shown as plain text with HTML tags.
All new text that is entered as richly-formatted text is displayed and captured correctly, as expected. |
Conclusion
When using the Long Text field in an MS Access database, you have to exercise some care in setting the Text Format property of the table field as well as its bound Text Box. Especially when making changes to the Text Format property, you have to make the changes consistent across both the table and the form.