Results 1 to 4 of 4
  1. #1
    kchadek is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Posts
    6

    Changing Font Size of Labels Depending on Text Length

    So I know there are many other threads similar to this, but I have searched all over the place with no avail.

    I have a report that prints labels (similar to avery labels) which pulls data from a query. These labels are all unique and vary in length. Due to the length variance, I want the font size to get smaller for labels with more characters. I want the text to go down to another line when necessary.

    In my report under the OnPage Event Procedure I wrote this:
    Private Sub Report_Page()
    If Len(Text2) > 20 Then Text2.FontSize = 8
    If Len(Text2) > 10 And Len(Text2) < 21 Then Text2.FontSize = 10
    If Len(Text2) < 11 Then Text2.FontSize = 14

    End Sub



    This works to some degree but the problem is that once there is a longer label, all of the proceeding labels are resized & the longer label that should have been resized was not.
    Click image for larger version. 

Name:	Designator Labels.png 
Views:	7 
Size:	5.5 KB 
ID:	17515

    Is there another place I should be writing this code? I looked under events for the textbox but there doesn't seem to be anything that would work since none of them would trigger when printing labels.

    Thanks in advance

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,608
    Hi -

    Is there another place I should be writing this code?
    Yes - try putting the code in the On Format event of the detail section of the report. You want it to run for each label, not each page.

    John

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    49,626
    Can try the report Detail section Format event.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    kchadek is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Posts
    6
    THANK YOU!!

    I read about the OnFormat event and looked all over but didn't realize I had to click on the 'Detail' bar to access that property sheet (I figured the OnFormat event would be a part of the text box)

    This was the last big step to this project. Thanks again!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Changing Field Length; Any Issues?
    By HMEpartsmanager in forum Database Design
    Replies: 22
    Last Post: 04-09-2013, 03:17 PM
  2. Changing Font Color and Size in table
    By FormerJarHead in forum Access
    Replies: 2
    Last Post: 01-09-2013, 01:04 PM
  3. MsgBox font size
    By GraeagleBill in forum Programming
    Replies: 4
    Last Post: 01-02-2013, 02:59 PM
  4. Replies: 0
    Last Post: 03-10-2012, 11:35 PM
  5. Font Size control
    By techexpressinc in forum Forms
    Replies: 2
    Last Post: 06-29-2011, 06:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums