473,503 Members | 1,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change text colour of part of text within text box on report

17 New Member
Hi

I have a text box on a report which is formatted to Rich Text.

The text box has a large amount of text and I would like to format some words to a different text colour, e.g. Red. I've been trying to do it in HTML but nothing is working. Maybe I can achieve this in VBA? However I was hoping there would be a simple way to do it within the text box - ?

Can anybody help please?
Thanks
Aug 25 '15 #1
7 11634
NeoPa
32,557 Recognized Expert Moderator MVP
Hi Laura.

I'm trying to look into this for you but I can find nowhere to specify that a TextBox be RTF. Can you explain how you did that for me please.

BTW I'm using 2010. Which version are you using?

PS. I just found the TextBox property called .TextFormat (Text Format).
Aug 25 '15 #2
NeoPa
32,557 Recognized Expert Moderator MVP
Hi Laura.

It seems if you want to change every occurrence of the three letters "red" to show in red text then you would use <font color=red>red</font>.

Some VBA to do this for you would be something like :
Expand|Select|Wrap|Line Numbers
  1. Me.{ControlName}.Value = Replace(Me.{ControlName}.Value _
  2.                                , "red", "<font color=red>red</font>")
NB. Careful, as this would also colour the last part of "Coloured" ;-)
Aug 25 '15 #3
NeoPa
32,557 Recognized Expert Moderator MVP
BTW. You do know that a special toolbar called the Mini-Toolbar will always pop up when you select text within such a TextBox which will allow you to make the changes manually don't you?
Aug 25 '15 #4
NeoPa
32,557 Recognized Expert Moderator MVP
In case it helps, this office.com link may prove helpful :
Insert or add a rich text field.

I was also able to discover a list of the HTML tags that are supported in MS RTF fields :
Expand|Select|Wrap|Line Numbers
  1. <div>,<font>,<strong>,<em>,<u>,<ol>,<ul>,<li>,<blockquote>
The first two tags support extra options as follows :
Expand|Select|Wrap|Line Numbers
  1. <font>: face, size, color, style(with BACKGROUND-COLOR only)    
  2. <div>: align, dir
Hopefully this will give you all you need to know, or at least give you a good head-start.
Aug 26 '15 #5
laurajchambers
17 New Member
Thanks for your replies, NeoPa.

I'm using Access 2007. To format the text box to Rich Text I went into the Property Sheet and changed 'Text Format' to Rich Text on the 'All' tab.

Unfortunately I don't want every occurrence of the word to be red font, so I don't think <font color=red>red</font> will achieve what I need it to?

I have tried the toolbar but it appears to change the font colour of the entire text box to red, even though I highlighted the word I wanted to change.

Thank you for the tag information. Do you know how I would include this within the text box please? I've tried to add it to the string, but when I then run the report it asks me for the parameter as it doesn't recognise it.

E.G.

=[Forename] & " " & [Surname] & " (" & [ID] & "). " & [Forename] & " requires ................"

How could I make the first Forename red, but not the second occurence?

Thank you for all of your assistance.
Aug 26 '15 #6
laurajchambers
17 New Member
Hi again, NeoPa

I managed to get your tag working. <font color=red>WORD</font>

The previous time I enclosed it within '&' as I thought it would need connectors. But I just removed those and it works perfectly.

Thanks for pointing me in the right direction - much appreciated.

Laura
Aug 26 '15 #7
NeoPa
32,557 Recognized Expert Moderator MVP
My pleasure Laura :-)
Aug 26 '15 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
8658
by: kiko | last post by:
How can I change the output text colour? Here is part of example source code: .... textcolor(4); cout << "text"; .... The "cout" doesn't work with "textcolor". I don't want to use "cprintf"....
4
23937
by: michael | last post by:
I have an html text string within a div, eg.: <div id="example">Text text text</div> I know its easy to change styles by using getElementById - for example: ...
1
2563
by: Terry | last post by:
I have a form which displays data from both the Student Details table and the Exam Details table. The Name (Text Box) control is from the Student Details table and the Withdrawn (Check Box)...
4
3785
by: Dwight | last post by:
I need to change the colour of text values within a table. For example "Software" being red, "Lab Software" blue etc. To change colour of number values simply, 1, entered into the format section...
1
4179
by: Santosh | last post by:
dear all i want to change text direction of text box with in datagrid control i am writting following code but it is not working. public void SetUpClientScript(object sender,...
4
1327
by: helraizer1 | last post by:
So far I have function color() { var box = document.getElementById('message'); box = box.style.color = "#FF0000"; }
18
7727
by: wizdom | last post by:
Help - change text on click - text has another onclick inside with php variables ---------- I think what I'm trying to do is simple. I have a 2 buttons on a page. 1 button allows a thread of...
1
1922
by: maheshgupta0248 | last post by:
Hi All, I have created a dialog based application in vc++ which includes some buttons.I want to give different colours for their borders and also for the text on them.Can u pls provide solution for...
2
1883
by: kent christensen | last post by:
So i have a report that will be seen by several customer around the world. I have done some research on ways to change some of the financial figures to show the correct currency. There are two...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.