Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2005
    Posts
    12

    Unanswered: Dynamically change label size in a report

    Hi guys

    I have got a lot of data coming into a text field and need to adjust the associated label to the same size as the text box. This should be simple enough...so why can't I find an answer?!
    I can't change it in the Report_Open() method, as the data hasn't been loaded yet. And I it doesn't seem to do anything when I put it in the Detail_Format() method. This is roughly what I have:

    Code:
       
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    
        Dim new_height As Integer
        new_height= Me.txtQ1Comment.Height
        Me.lblComment1.Height = new_height
    
    End Sub
    I must be missing something...but what?
    Thanks a lot,

    kt

  2. #2
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    try the On_Page event - that happens after the data is loaded, but before the page is formatted

  3. #3
    Join Date
    Nov 2005
    Posts
    12
    I've tried messing around with the Height method, but it doesn't seem to be having any effect on the report page. I've tried setting it from within Report_Page() and Detail_Format() methods but I am obviously trying to access the Height property incorrectly, is there another way to access it?
    Thanks again for your help.

    This is the load function you are referring to isn't it?
    Code:
    Private Sub Report_Page()
        
        Dim counter As Integer
        counter = Me.Q1Comment.Height
        Me.lblComment1.Height = counter
       
    End Sub

  4. #4
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    Out of curiosity, what number are you assigning to the height property?

    Although the property sheet is measured in inches, the actual property when accessed through code is measured in twips. There are something like 2440 twips to an inch.

    Perhaps your number is too small, and Access is kindlly fixing it for you without telling you.

    tc

  5. #5
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    It is actually 1440 twips per inch. If you can explain more about what you are trying to accomplish someone might be able to give you alternatives. But I would suggest letting Access make the height adjustments by changing the label to a text box and changing the Can Grow property to Yes.

    Where are you getting the data for the label? Is it something you can do in a query?

  6. #6
    Join Date
    Nov 2005
    Posts
    12
    Quote Originally Posted by tcace
    Out of curiosity, what number are you assigning to the height property?

    tc
    Hey tc
    Yeah I'm familiar with the idea of twips, and I know it's 1440 per inch, but I tried setting a small test textbox to set it's height and width to 1440 to see if whether the report_page() method would change it, and nothing happened! It actually makes more sense to me to use the detail_format() method, as this cycles through each detail, but I can't get it to work either.

    Quote Originally Posted by DCKunkle

    I would suggest letting Access make the height adjustments by changing the label to a text box and changing the Can Grow property to Yes.

    DCKunkle
    Hey dc
    The labels carry fixed information(descriptions), which I would like to expand so it is in line with the textbox, which can grow.
    The label's information will never change, so there is no need for the grow function, but I do need to set it to the same height as the text field.

    It's easier to understand if you look at the attached screenshot, which shows why I need to expand the label. If I use lines to join the sections up, they also won't grow according to the text field.

    I've spent all day trying to figure out what I think should be a relatively simple thing!

    kt
    Attached Thumbnails Attached Thumbnails report_sample.JPG  

  7. #7
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    ok, here's what I learned:

    1) The Height property of a text box is not availble while a report is printing.
    2) None of the events avaiable at time of print caught the Detail being resized to accomodate the larger text box when it grows to fit larger chunks of data.

    So, I took a different approach: I put the detail in a sub-report and made the border of the label transparent. The sub-report has a solid border, however.

    Attached the DB and a screen shot of the report.

    tc
    Attached Thumbnails Attached Thumbnails Sprite 6.jpg  
    Attached Files Attached Files
    Last edited by tcace; 04-19-06 at 23:19.
    have fun!

    Todd S.
    click to email


    Independent Development Consultant
    Biz db & reports - SQL, Access, Crystal, Seradex and more
    Small, custom, unique programs - Office, VBA, .NET


    _________________________________________________
    Favorite message from Windows:
    There was an error displaying the previous error message

    Sadly, there was no error number to look up ...

  8. #8
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    Did you get it working?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •