• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

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!
0
Nero83
Asked:
Nero83
  • 6
  • 5
1 Solution
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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>
0
 
Nero83Author Commented:
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
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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.
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
Nero83Author Commented:
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.
0
 
Nero83Author Commented:
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?
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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.
0
 
Nero83Author Commented:
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.
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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.
0
 
Nero83Author Commented:
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>"
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
I'd think it would be:

="<div>Beginning text <font face=verdana>" & [transfereevesting] & " </font><font face = arial>the remaining part of the text</font></div>"

And don't forget the ending </font> tag (I highlighted it in bold).

You might also find it easier to create that "field" in the underlying query, assuming your static text doesn't change.
0
 
Nero83Author Commented:
Thanks for all your help, Scott.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now