Link to home
Start Free TrialLog in
Avatar of avoorheis
avoorheis

asked on

keep label same height as text box when growing or shrinking

How can I keep a label (or text box), that's on the same row, the same height as a text box on the same row that can grow or shrink? The text box's content can change, but the label either has a single character or is empty (tried using a text box instead of label with formula similar to the text box that is growing/shrinking).

This must happen a lot....and thanks for looking
Avatar of GRayL
GRayL
Flag of Canada image

Text boxes grow and shrink to accomodate text at a given font and size.  The text in the caption of a label is similarly configured with a font and a size.  If the text box now grows to accomodate more text do you mean you want the size of the font as well as the size of the label to grow accordingly?  For a text box that has grown to 4 lines you now want the label text to be 4 times as high as it was when the textbox was only one line.  Form space is valuable real estate and I can see too much of it being eaten up by oversized labels.  In addition as the text height grows so does it's horizontal size.  Do you have that much room to the left of the textbox to allow a label to grow to 4 times its original size?  Why not put the lable above the textbox for those controls which will grow and save the left aligned labels for the single rowed textboxes. Just my 2¢.  
Avatar of avoorheis
avoorheis

ASKER

The text box is almost the width of the report, except for the label, which is just to the left of it. Right now I have a dash "-" in the label, which would be good to have centered, but, at least want the border of the label to match the height of the textbox. The size of the font in the textbox stays the same, just the data changes (more/fewer lines, or shrinks completely if nothing).

I'd really like to have a square bullet centered to the left of the text box, just haven't gotten that far yet, and may just settle for a dash alongside the first line of the text box.
Avatar of clarkscott
me.YourLableName.height = me.YourTextField.height

Scott C
In the OnFormat event of the detail section set the height of the label = height of the textbox.
--
JimFive
thanks for the vb solutions, although I was hoping to stay away from that as this will be a fairly complex report with possibly up to 6k records, so, just trying to eliminate as much overhead as possible. But, it seems there may not be a simple solution.
I have a fairly straightforward solution with the 'bullet' but I am occupied for the rest of the day.  I'll check in tomorrow and if the question is still open, I'll post then.  Thanks,

Ray
   <-- I created a small label just to the left of a single line textbox the same height as the textbox.  My Font for the report was Arial so I used the Windows Character Map to find the Arial 'Black Square' symbol and pasted it in the Caption property of the label, as you see at the beginning of this post.    Now when the report runs, you at least have a square bullet at the top of and to the left of your multi-line text boxes.  I am still trying to figure how to use the retreat event of the Detail section to allow positioning of the 'Top' property of the label to somewhat less than half the height of the textbox after it has been populated, but before it is actually printed or in preview.
In the edit panel of this post I had pasted the 'Black Square", and now I see it disappears when one clicks 'Submit'.  Anyway, the 'Black Square' exists and can be pasted to the Caption property.  BTW I have a test table with a single memo field containing both a 12 line text sample and a two line text sample.  The form has the label and a single-line textbox side by side and the textbox extends across the page.  When I run the form, there is the black square lined up with the top line of text.  I've spent several hours now trying to move it down by adjusting the Label0.Top property so it will appear half way down the text for both records - at run time.  There's the trick laddie!
Thanks for taking on the challange Ray. I was thinking this would have been a pretty standard requirement, but, aparently not. Too bad there isn't a vertical centering option for text boxes and labels.
ASKER CERTIFIED SOLUTION
Avatar of GRayL
GRayL
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for all you work Ray, I'll play around with it and see what I can do. Good to know.
I did find out that in both the Detail_Print, and Form_Page events you can 'add' items like lines and circles to the page.  Thus in the Detail_print event, where you are looking at the detail for a given record, you can use the Line method to draw lines and rectangles.  You could then put a solid bar down the left side of a variable sized textbox in the Detail_Print event using Me.Text0.Left, Me.Text0.Top, and Me.Text0.Height  as references for the line method.  Seem like a plan?
Looks like I did not see my prevous post;-)  Thanks and good luck with the project.