Link to home
Start Free TrialLog in
Avatar of Nero83
Nero83Flag for United States of America

asked on

How can I change font "mid-stream" in a text box in Access 2010?

I have a text box in an Access 2010 report.  Mostly it is pre-typed text, but has the value of a text field sandwiched in between.  I would like to have the first part of the text box one font, then have the text value another font, and then return to the first font for the rest.  I would like to have it all within one text box so that it wraps correctly, and can grow or shrink if necessary.
I looked for some kind of formatting string I could insert, such as
="This certifies that"&[namefield]&"is a member of the organization" would turn into ="This certifies that"&Format([namefield], fontname)&"is a member of the organization"
but could find no such thing.
Thanks, Experts!
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

You can use a RichTextBox in 2010, and then format it using standard HTML or RTF commands. HTML is by far the simplest way to deal with text formatting, as RTF can be very difficult to get right.

An example would be:

This is the first font and <font face="verdana">This is the second font!</font>
Avatar of Nero83

ASKER

Scott,
Thanks for the reply.  I can't change it to a RichTextBox in report design view.  My table only contains the value that's sandwiched in the middle of the text currently.  How would I go about setting this up?
Chris
Sorry, I didn't explain myself well.

You must change the Textbox from "Plain Text" to "Rich Text" in design view. This is on the property sheet Data tab.

My table only contains the value that's sandwiched in the middle of the text currently
I'm not sure what you mean by that.
Avatar of Nero83

ASKER

Thanks!! I got the text box into Rich Text. I have a problem now when I try this an error message pops up: The expression you entered contains invalid syntax.
This is my text box where I just tried changing the font on the word "all":
="                   THIS CERTIFIES THAT " & [TRANSFEREEVESTING] & " is the owner of one membership Series of " & [LONGNAME] & ", a non-profit mutual benefit California Corporation which may not make distributions to its members except upon dissolution, and is entitled to <font face="verdana">all </font>the benefits and privileges of membership in said Corporation, and subject to all of the terms, conditions, and restrictions, as set forth in the Articles of Incorporation, By-Laws, and Occupancy Agreement of said Corporation."

Thanks for the help...this one is new to me.
Avatar of Nero83

ASKER

Sorry...in this case I am using 2013...I am unfortunately using 2010 and 2013 in different offices to work on the same database...maybe that's causing problems with this?
If you remove the <font ..> tags, does it work as expected?

What is [TRANSFEREEVESTING]? If that's a Field or Control, you should preface it with the correct qualifier. For example, Me.TRANSFEREEVESTING.
Avatar of Nero83

ASKER

Yes, without the font tags it's fine (except it's all one font of course).

Yes, [transfereevesting] is a field containing a text value.  This is the field that I need to be a different font than the remainder of the text box.  I've never had to preface one of these with a qualifier before, I've always just concatenated it into the rest of the text with ampersands.

Thanks.
Sorry - been a while since I worked with Rich Text. You have to use a different format when saving.

Here's an example of a Rich Text field that I created and then modified the font and such using the interface,

<div>Test to <strong>determine how</strong> Access stores this for<font face=Belgium> </font><font face=Belgium color=red>rich text</font>.</div>

Open in new window


You can see it's enclosed by <div> tags, so change your code to show this sort of structure. Also, note that that attributes of the <font> tag are NOT enclosed in single or double quotes. The exception to that would be if an attribute value contains a space. For example:

<div><u>Your Original Text Here</u> with the <font face="Arial Black" color=red>new font here</font></div>

Open in new window


Note in the above I've chosen Arial Black, and Access stored it with double quotes around the name.
Avatar of Nero83

ASKER

Thanks!  I'll try on Tuesday when I get back to work.  Before then, I still have questions:

I guess this is all preceeded by an equal sign and quotes to enclose the text except around the field name, and that I should use the same end-quote + ampersand + [field name] + open-quote + remaining text.

="<div>Beginning text "& <font face=verdana>[transfereevesting] </font>& "<font face = arial>the remaining part of the text</div>"
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nero83

ASKER

Thanks for all your help, Scott.