SOLVED

Format text box as italics and blue

Steel Contributor

Experts, how would I format the [txtSection] as italics and blue? 

 

=[Short Description] & " [" & [txtSection] & "]"

25 Replies

@Tony2021 

 

You'll need to convert to a Rich Text data type to support having two different formats applied.

 

Or, you could place two Plain Text textboxes side by side for the two different formats, with the appropriate color and font applied to each.

George, thank you.
My fields are in a report if that matters.
My field is not a rich text either.
I dont think having 2 text boxes side by side would work since the field [Short Description] can grow and I need to have the txtSection at the end of the last word of field [Short Description]. Is there another trick you might know of?

I thought I could simply add the word format([txtSection],"vbBlue" (like you would a currency field) but I guess I can not do that.

Unfortunately, no. Access provides Rich Text for tasks like this. It relies on HTML to format the text in that field. Otherwise, the control is a unitary object containing Plain Text that can only take one format.

On the other hand, converting the field in the table and in the report should not be all that onerous.
agree. you should select Rich Text as Text Format for your Unbound textbox.
on its ControlSource:

=[Short Description] & " <font color=""#0072BC""><em>" & [txtSection] & "</em></font>"

Hi,

 

A 20 years ago Stephen Lebans demonstrated how to do this in reports using the Print method. You can still download e.g. Luiz Claudio's derived example at http://www.lebans.com/mixbold-plain.htm which by accident even colors sth in blue. However, you have to know VBA a bit to understand and adjust it to your needs.

 

Servus
Karl
************
Access News
Access DevCon

@arnel_gp 

George, I have made the change of both fields to Rich Text.  The output seems unchanged.  I do remember that sometimes you could get extranneous characters (# sign or some < > or others).  I do not see any of those characters in the conversion.  

Arnel, thank you.
Should I populate the above with my font and not sure if I need to populate em with something?

The output looks like this (no change in text color and I see the codes.  

Tony2021_0-1642078735084.png

 

@Tony2021 You should have a Ribbon Tab enabled for the Rich Text controls which offers the options of font and color, etc. No need to enter the markup manually.

George, but since I have 1 text box that concactenates (not sure if that is an accurate term) then I would think I would need to add the formatting as Arnel suggested since I want to change the color and add italics for only 1 of the fields in the concactenated text box. maybe I am not following.
Yes, that's a good point. You may well have to concatenate the formatting in. The best solution is trial and error. If I get time here I'll look at it too.

Actually, now that I think about it, you might even have to do the concatenation in VBA and put the resulting string into the unbound control. There's more than one way to get most things done; the trick is to keep an open mind about the possibilities.

@Tony2021 

 

Here's an even wilder idea. Make at least one of the source fields Long Text in Rich Text format. Apply the required formatting in that field. When it is concatenated into this display field, maybe that will bring along that formatting....

@George Hepworth Yes, that ought to work if you can manage it. Maybe a third, hidden, field with the appropriate formatting applied so that the visible field looks normal, but the formatted field is the one concatenated into this unbound display control.

 

GeorgeHepworth_0-1642090577278.png

 

@George Hepworth 

George, yes I am open to anything. I placed a separate field with the formatting (I assuem I just simply go to Home then formatting section and select the color I want and I do not go into the field properties bwo the properties sheet. I do not see the formatting in the display field still. I also redragged the fields into the report to make sure the RTF came with it. I do see that you managed to do it per the pic above. If it matters the field I want to format is at the end of the display field. I see yours is at the beginning it appears.

 

here is my text box code:
=[Short Description] & " [" & [txtSection] & "]"
txtSection is the one I need the formatting on.

I'll upload the sample so you can see how I did it. It should just be a matter of the order of the concatenated strings. Gimme a few minutes to tidy up.
thank you....
best response confirmed by Tony2021 (Steel Contributor)
Solution

@Tony2021 

 

I added this to an existing demo I had.

 

@George Hepworth 

Hi George, I see how its setup and I think I am replicating on my side. I dont see how you set the color of the text box Project Status?  I think you are doing it some special way because I can not change the color of that box. 

Tony2021_0-1642114512211.png

 

 

@Tony2021 

 

You can format it  using the ribbon tab.

GeorgeHepworth_0-1642115495996.png

 

 

@George Hepworth 

 

George, 

Sorry but I dont follow.  

If I go to Home / Text Formatting and choose the font color, it doesnt change from Red.  

here below I changed it to yellow.

Tony2021_0-1642117111870.png

 

Its still RED when the form opens:

Tony2021_1-1642117199153.png

 

Let me know what I am doing wrong. 

 

I can't see anything really, except that your screenshot appears to be in design view. I made the format changes in normal, single view.
1 best response

Accepted Solutions
best response confirmed by Tony2021 (Steel Contributor)
Solution

@Tony2021 

 

I added this to an existing demo I had.

 

View solution in original post