Solved

Automatically reduce font size on a report to fit text box

Posted on 2009-05-09
9
1,405 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 500 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
Independent Software Vendors: 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!

 

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

Independent Software Vendors: 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!

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 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