Solved

Automatically reduce font size on a report to fit text box

Posted on 2009-05-09
9
1,366 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
  • 4
  • 3
  • 2
9 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
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 119

Accepted Solution

by:
Rey Obrero 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
 

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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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 119

Expert Comment

by:Rey Obrero
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 119

Expert Comment

by:Rey Obrero
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ms/access ftp / SFTP 3 32
Help writing a query 6 71
Track name AutoCorrect info 14 46
Need more help autopopluating a number field 17 33
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

911 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now