Go Back   Access World Forums > Microsoft Access Reference > Code Repository

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 12-02-2016, 06:59 AM   #1
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 10,773
Thanks: 40
Thanked 3,494 Times in 3,381 Posts
CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice
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.

__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
The Following User Says Thank You to CJ_London For This Useful Post:
isladogs (04-06-2017)
Old 04-09-2017, 05:16 PM   #2
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 9,292
Thanks: 105
Thanked 2,492 Times in 2,288 Posts
isladogs is a name known to all isladogs is a name known to all isladogs is a name known to all isladogs is a name known to all isladogs is a name known to all isladogs is a name known to all
Re: how to find richtext codes for highlight, underline etc

Hi

Thanks for this
I did exactly that & after a bit of tweaking got it working - example attached

One comment - although you need single quotes in the SQL expression as shown above, you will need to change them back to double quotes at the end or the text won't display the way you wanted.

Alternatively perhaps it would work with double " quotes?
Attached Images
File Type: png ReportWithHighlightedText.PNG (58.3 KB, 71 views)
isladogs is offline   Reply With Quote
Old 04-13-2017, 03:45 AM   #3
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 10,773
Thanks: 40
Thanked 3,494 Times in 3,381 Posts
CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice
Re: how to find richtext codes for highlight, underline etc

here is a simple db to make life a bit simpler
Attached Files
File Type: zip RichTextCode.zip (19.8 KB, 174 views)

__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
The Following User Says Thank You to CJ_London For This Useful Post:
usm01 (12-27-2017)
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Allow color-codes for syntax highlight in SQL view? casshyr General 1 02-15-2016 12:27 PM
Getting Text from Richtext PC User Modules & VBA 0 08-08-2006 03:23 PM
RichText Find Function PC User Forms 0 09-07-2004 03:30 PM
Richtext problem Butch General 0 05-19-2004 01:48 AM
[SOLVED] Post codes/ Zip codes input masks angelrichardson General 3 02-11-2003 07:46 AM




All times are GMT -8. The time now is 09:12 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World