Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

Access 2003 Report - Conditional Formatting of Font Size

Hello all.
MS Access 2003 SP2
This database fills blanks on a US Customs form.  The Port Director has asked that I increase the font size on the entry fields so that it is easier to read when the fax is received.  (I know, there are 100 ways to email it and get a "pretty" copy, but they require the fax.)
Increasing the font size causes some records to extend beyond the allotted space on the form, cutting off portions of the data.
For example:  "Dublin, Ireland" fits fine, but "Purfleet, United Kingdom" gets cut off.
1) I cannot wrap the text.
2) I cannot modify the alloted size of the field.

I would like for the control to use font size 12 for everything that will fit, and either 11 or 10 based on the length of the data.  (I have determined that 10 is the smallest necessary.)

What I need is some combination of conditional formatting and whatever flags the "Can Grow" attribute.

I need to get this in production immediately, so any ideas will be greatly appreciated.
1 Solution
i'm confused, do you mean form or report?
Hi bgothard, something like this should work:

Assuming you have a field called txtName in the Detail section of the report *and* you know that 23 character is about the maximum you can fit, add this to the report's Detail_Format sub:

If Len(Me.txtName.Text) > 23 Then
    Me.txtName.FontSize = 10
    Me.txtName.FontSize = 12
End If

You will need to play with it a little because unless you're using a fixed-width font each word will be a different actual size depending on the letters in it (iii is smaller than MMM on the printed report).

Hope that helps,
bgothardAuthor Commented:
Sorry.  It is an Access REPORT.  

The end result is a US Customs and Border Protection FORM 7512. (Official name.)  In this context, please ignore references to "form".  
Have you tried using Arial Narrow size 12.  The letters are bigger, but not as wide.

If not, in the OnFormat event of the section where the field is. you can test for the len() and change the font size of the text box accordingly.  The len() is not perfect as we are not using proportional font, but is an easy alternative.
bgothardAuthor Commented:
Thanks Grendel777!  That worked like a charm.  I added an ElseIf to step down through 11 to 10.  It's not a perfect solution because I'm using Arial, but it solves the problem with a minimum of fuss. (And isn't that what it's all about anyway?)


I appreciate the suggestion, ragoran, and I'll keep it in mind.  I already implemented Grendel777's solution before I read yours.  (The code, not the font.  The narrow font doesn't fax well, either.  I tried that earlier and they didn't like it.  Good suggestion, though.)

Thanks again!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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