Unanswered: Dynamically change label size in a report
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:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim new_height As Integer
Me.lblComment1.Height = new_height
I must be missing something...but what?
Thanks a lot,
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?
Private Sub Report_Page()
Dim counter As Integer
counter = Me.Q1Comment.Height
Me.lblComment1.Height = counter
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?
Out of curiosity, what number are you assigning to the height property?
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.
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.
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!
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.