473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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

✓ answered by NeoPa

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" ;-)

7 11607
NeoPa
32,556 Expert Mod 16PB
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,556 Expert Mod 16PB
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,556 Expert Mod 16PB
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,556 Expert Mod 16PB
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
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
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,556 Expert Mod 16PB
My pleasure Laura :-)
Aug 26 '15 #8

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

Similar topics

3
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
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
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
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
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
by: helraizer1 | last post by:
So far I have function color() { var box = document.getElementById('message'); box = box.style.color = "#FF0000"; }
18
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.