Solved

Automatically reduce font size on a report to fit text box

Posted on 2009-05-09
9
1,351 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
In other words, I'd like the text to dynamically fill the locked size of the text box on the report.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:SteveL13
Comment Utility
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
Comment Utility
<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
Comment Utility
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
Comment Utility
hi jeff,

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



0
 
LVL 34

Expert Comment

by:jefftwilley
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

771 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

11 Experts available now in Live!

Get 1:1 Help Now