Results 1 to 2 of 2
  1. #1
    CostasD is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2022
    Posts
    3

    Resize font to fit label

    Hi,

    I have a report with labels (name, surname) that populate from a database.
    Sometimes the name and surname are long enough and exceed the length of the label
    How can I resize the font to fit in the label?

    Thank you





  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    Something tells me your report design is unusual, and that may be the real problem. Usually data goes into (e.g.) textboxes, not labels.
    You would have to decide at what character count you will do this, as there's no way (at least that I'm aware of) to do anything automatically. The possible problem with that is, unless you use a fixed width font x number of characters have different widths depending on the characters present. W's take up a lot more space than I's.
    You would have to write code that gets the character count of your text and reduce the font size accordingly. Something like
    Code:
    Select Case Len(Me.lblNames)
      Case Is > 50
         Me.lblNames.FontSize = 8
      Case 25 To 50
         Me.lblNames.FontSize = 10
      Case Else
         Me.lblNames.FontSize = 12
    End Select
    Your report design might require such code to go somewhere other than the report load event.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 6
    Last Post: 07-12-2019, 09:29 AM
  2. Changing font color of just part of a label
    By NGFLNG1 in forum Access
    Replies: 3
    Last Post: 09-11-2015, 11:02 AM
  3. Replies: 3
    Last Post: 01-22-2015, 12:33 PM
  4. Replies: 2
    Last Post: 12-09-2014, 09:24 AM
  5. Replies: 1
    Last Post: 04-29-2010, 05:15 PM

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