Make label grow with text box

RexesOperator

Registered User.
Local time
Today, 18:53
Joined
Jul 15, 2006
Messages
604
I am using can grow in a text box.

How do I get the associated label to grow by the same amount? For example the width of the label is 5 cm and the width of the text box is 5 cm. With can grow the text box may expand to 8 or 10cm or more, depending on the content. But the label doesn't change. I need the label to grow by the same amount as the text box. The label font is white and the label background is light gray - so it is pretty obvious when it doesn't change.
 
Not sure, but maybe ...

Code:
Me.lblLabelName.Width = Me.txtControlName.Width

-dK
 
BTW I did do a search on this, but the results were all about mailing labels (not surprisingly).

Looked promising, but didn't work. This is what I tried.

Private Sub Report_Open(Cancel As Integer)
Me.lblTransactionsID.Width = Me.txtTransactionsID.Width
End Sub
 
Gosh. I don't know then without doing serious investigating.

Anyone else off the top of their heads?

-dK
 
The command:

Me.lblLabelName.Width = Me.txtControlName.Width

Is good, you just have to put it in the Detail Section's OnFormat event.

You want it to fire for each row.

Wayne
 
Wayne,

The help menu says this as well. It says something about the entire rows only being able to be formatted, and that the sections of the objects should be used for events like these. Just thought I would point that out...
 
I'm not quite sure how you're working with Width in a Cangrow situation.
Cangrow affects the vertical height of data controls.
So you need to consider the Height property don't you? Width can be permanently assigned at Design time.

The problem you then have is that the new height property of the extended control isn't available until Print time (i.e. it's accessible in the section's Print even) but by then you can no longer adjust the size of controls (which must be done in the Format event).

What you could probably do is use some of Stephen Lebans Report utility examples to determine the height that a control will be by the time it's grown - and size all the controls to that size in the Format event.

Alternatively - draw the borders on your controls manually (again Stephen offers examples of drawing shapes onto reports on his examples page).
Which is http://www.lebans.com/toc.htm by the way - incase you've not been there (which is probably unlikely I know - given how huge a figure Stephen is to the Access world).
 
I'm not quite sure how you're working with Width in a Cangrow situation.
Cangrow affects the vertical height of data controls.
So you need to consider the Height property don't you? Width can be permanently assigned at Design time.

That explains what I'm getting. I want the width of the label and the text box to change as needed - not the height. Do you know if that can that be done?

Re Stephen Lebans - been to his site many times. I will take a look at his utilities.
 
So you want the width - not the height... in which case CanGrow isn't what you want.
You need functionality provided by Stephen.
His work on Font widths is the standard - and you'd be able to use it in the Format event to appropriately size the width.

I assume you're showing borders of these controls - hence why the width is important.
Just showing the text is the easy way out. Leave the borders up to the user's imagination. :-)
 
Cool! Thanks. Now - how does this work?

I did look at Lebans MakeFit, but that was forcing the font to fit the fixed width of the text box (at least how I understood it). This is EXACTLY what I want!
 
Last edited:
RO,

It uses the OnFormat event of the report's Detail section and issues the
command as per post #2 in this thread.

The width of the controls are in TWIPs and my calculation of the desired
width is VERY primitive. One should consider the Font and Font Size, but
I just used something simplistic to show the principle.

Not very sophisticated, but hope it helps.

Wayne
 
It more than helps - it works. I was wondering what the units are and I have played around with various lengths. It fits what I need perfectly.
 

Users who are viewing this thread

Back
Top Bottom