resizing fonts

G

Guest

I have an application with a couple of dozen different reports. They are
reproductions of standardized state forms so I can't change the layout of the
report. All my fields are set to a 10pt font. The problem is that sometimes
the data won't fit. Can Shrink/Can Grow won't help because I can't expand the
field sizes. The only way to make things fit is to lower the font size. I
want to use the largest font size possible that will accommidate the data in
each field. (If 10 is too big, try 9. If 9 still too big go to 8 etc.)

I've seen this code for the On Format property

If Len([NameField])> 20 then
[NameField].FontSize = 8
Else
[NameField].FontSize = 10
End If

This will work but I've got a bunch of reports with who knows how many
fields. Is there some way to get the result I want without using the On
Format code for every field on every report? I hoping for a miracle shortcut.

TIA,
Lynne
 
F

fredg

I have an application with a couple of dozen different reports. They are
reproductions of standardized state forms so I can't change the layout of the
report. All my fields are set to a 10pt font. The problem is that sometimes
the data won't fit. Can Shrink/Can Grow won't help because I can't expand the
field sizes. The only way to make things fit is to lower the font size. I
want to use the largest font size possible that will accommidate the data in
each field. (If 10 is too big, try 9. If 9 still too big go to 8 etc.)

I've seen this code for the On Format property

If Len([NameField])> 20 then
[NameField].FontSize = 8
Else
[NameField].FontSize = 10
End If

This will work but I've got a bunch of reports with who knows how many
fields. Is there some way to get the result I want without using the On
Format code for every field on every report? I hoping for a miracle shortcut.

TIA,
Lynne

See if this will help.
http://www.lebans.com/makefitsingle.htm
 
M

Marshall Barton

Lorien2733 said:
I have an application with a couple of dozen different reports. They are
reproductions of standardized state forms so I can't change the layout of the
report. All my fields are set to a 10pt font. The problem is that sometimes
the data won't fit. Can Shrink/Can Grow won't help because I can't expand the
field sizes. The only way to make things fit is to lower the font size. I
want to use the largest font size possible that will accommidate the data in
each field. (If 10 is too big, try 9. If 9 still too big go to 8 etc.)

I've seen this code for the On Format property

If Len([NameField])> 20 then
[NameField].FontSize = 8
Else
[NameField].FontSize = 10
End If

This will work but I've got a bunch of reports with who knows how many
fields. Is there some way to get the result I want without using the On
Format code for every field on every report? I hoping for a miracle shortcut.


Too bad, but there's no magic wand for this. OTOH, you can
minimize the amount of work.

First, create a public procedure in a standard module to do
the work:

Public Sub AdjustFont(sec As Section)
Dim Ctl As Control

For Each ctl in sec.Controls
If ctl.Tag = "Adjust" Then
If Len(ctl) < 20 Then
ctl.FontSize = 10
Else
ctl.FontSize = 8
End If
End If
Next ctl
End Sub

For each report where you want to do this, set each text
box's Tag property to "Adjust". This can be done in one
shot by holding the Shift key down and clicking on each text
box. When you have the batch of text boxes selected, type
Adjust in the Tag property to set them all.

Then add a call to the procedure in each report section's
Format event that contains one of these text boxes. For
example:

AdjustFont Me.Detail
or
AdjustFont Me.Section(n)

Note that the test for Len(ctl) < 20 is very coarse and,
depending on the font and the displayed characters, may not
deal with all possible situations. Stephen Lebans'
TextHeightWidth procedure at www.lebans.com is far more
precise. If you want this degree of accuracy, replace your
If Len(ctl) < 20 block with this kind of code:

For fs = 10 To 5 Step -1
If fTextWidth(ctl) < ctl.Width - 10 Then Exit For
Next fs
ctl.FontSize = fs
 
H

HungTano

I have a question, in generally :
I want to fix the text data in field on control of report, no grow no shrink
no underline. How can I adjust fontsize automaticcaly when report is opened.
 
M

Marshall Barton

HungTano said:
I have a question, in generally :
I want to fix the text data in field on control of report, no grow no shrink
no underline. How can I adjust fontsize automaticcaly when report is opened.

It's not at all clear what you are trying to do. Previous
posts in this thread seem to answer that question except for
the part about using the Open event. The Open event occurs
before the report's data is available, so I don't see how
that ties into your question. Generally this kind of thing
needs to be done in the Format event of the section that
contains the text box.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top