how to find richtext codes for highlight, underline etc
You might use this with the objective of highlighting searched for text in a text field, or perhaps to format the date and time values in a single field a different colour (although date/time fields would then be text format). Will also work with numbers but they also will be converted to text. Note this is only applicable for access 2007 and later.
1. create a temporary table with a memo (or long text) field and set field to richtext
2. populate the table with some words and highlight/bold/underline as required
3. create a query based on the temporary table and in the query grid put
Expr1:[mymemofieldname] & " "
4. run the query and you will see something like
<div>hello <font style="BACKGROUND COLOR:#FFFF0"world</font></div>
to use this
5. in a query, create a column something like
highlighttext: "<div>" & Replace([myfield],"world","<font style='BACKGROUND-COLOR:#FFFF00'>world</font>") & "</div>"
note the use of single quotes
if myfield is a memo field already set as rich text and you don't want to preserve the existing formatting, then substitute [myfield] with PlainText([myfield]). You might need to do this if the formatting overlaps. For example if you are identifying 'World', then World will not be found because of the existing formatting effectively splitting the word - ...W</strong>orld....
note that highlighting does not work when the query is run - to see the effect, create a form (can be datasheet) and set the textbox text format to rich text.
A little thanks goes a long way. If you have found this post useful, please tick the thanks button