?
Solved

Automatically reduce font size on a report to fit text box

Posted on 2009-05-09
9
Medium Priority
?
1,424 Views
Last Modified: 2012-05-06
Is there a way to autimatically have the font size reduce on a report to fit the size of the text box.  I do not want the size of the text box to change...  just the font within the box.
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24344095
try this in the format event of the Detail section of the report


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
me.text0.FontSize = IIf(len(me.text0.value) > 15, 10, 14)

End Sub

just change the values

0
 

Author Comment

by:SteveL13
ID: 24344206
Hmmm, this isn't working quite right.  If I have a data sting with 12 characters it reduces it down to about a 12 point text but if the field only contains 12 characters then I want the text to be a full 16 pt. type as per the design of the report.
Here's my adjusted code...

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    Me.txtCustomer.FontSize = IIf(Len(Me.txtCustomer.Value) > 16, 14, 12)

End Sub
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 24344240
this doesn't make sense
<If I have a data sting with 12 characters it reduces it down to about a 12 point text but if the field only contains 12 characters then I want the text to be a full 16 pt.>


this line
Me.txtCustomer.FontSize = IIf(Len(Me.txtCustomer.Value) > 12, 12, 16)

will follow the logic  if number of characters > 12  font size is 12 else font size is 16

is this what you want?
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:SteveL13
ID: 24344245
In other words, I'd like the text to dynamically fill the locked size of the text box on the report.
0
 

Author Comment

by:SteveL13
ID: 24344301
The code you provided is doing exactly what I would expect it to do but I probably didn't explain what I want well enough.  What I really want is to have the data fill the text box dynamically but not to exceed 16 point type size.  Can this be done?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24344438
<What I really want is to have the data fill the text box dynamically but not to exceed 16 point type size>

i wouldn't even dare to start doing that..
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 24348581
I've done something like this

Select Case True
        Case lngArtist < 12
           Me.ARTIST.Properties("FontSize") = 16
        Case lngArtist < 14
           Me.ARTIST.Properties("FontSize") = 14
        Case lngArtist < 16
           Me.ARTIST.Properties("FontSize") = 12
        Case lngArtist < 18
           Me.ARTIST.Properties("FontSize") = 11
        Case lngArtist < 20
           Me.ARTIST.Properties("FontSize") = 10
        Case lngArtist < 22
           Me.ARTIST.Properties("FontSize") = 9
        Case lngArtist < 24
           Me.ARTIST.Properties("FontSize") = 8
        Case Else
           Me.ARTIST.Properties("FontSize") = 8
End Select

it is based on how many characters for a particular font fit into a fixed text box.

J
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24348602
hi jeff,

looks like an exploded version of the the IIF(...) i posted above.



0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 24351346
Hey Cap!
I used this for a set of reports that I created to make Karaoke song selection lists. The song titles and artist names are all various lengths. I don't remember the font nor the size of the textbox, but I measured how many characters fit into a specific space. I'm sure the lengths vary for different fonts. But the method works.
Good to see you!
J
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question