Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TextBox height dependant on Height of other TB 1

Status
Not open for further replies.

ThinWhiteDude

Technical User
Sep 21, 2004
97
US
I have been trying to figure out coding/property setting to make a textbox on a report the same height as another textbox.

Here's the story:

I am using a textbox as a color background for several textboxes in the detail section of the report. This "colored box" is behind all the other textbox controls and spans the width of the Detail section. Some of the other controls grow and some don't. My wish is that this one in the back will always be as tall as the tallest textbox (dtmDuration). I know which control will have tallest height and I have it's Can Grow property set to Yes. How can I make the background textbox's height property dependant on the dtmDuration textbox's height?

Sorry if this sounds muddled. Any help will be appreciated.

TWD

 
In the On Format event of the detail section, place code like this:
Code:
Me.txtColorBox.Height = Me.dtmDuration.Height


I'm CosmoKramer, and I approve this message.
 
CosmoKramer,

I tried your suggestion, but it didn't work.

Seemed like it should have, so I checked all properties again. Both controls are visible, both have Can Grow set to "Yes" (even though that doesn't help the color box as it's very wide), in design they have regular height settings, but dtmDuration grows when needed.

Could I have missed anything. . .?

thanks,
TWD

 
TWD,

I know it sounds crazy, but try setting CanGrow and CanShrink to No....

I'm CosmoKramer, and I approve this message.
 
CosmoKramer,

Wasn't sure which control(s) you meant so I did that on both; didn't worked. Played around with some combinations of those properties with no luck. this is driving me nuts, but I appreciate your efforts to help me,
TWD
 
You want to set the colored text box properties to No. I didn't realize that myself until I went in to verify that the syntax I gave you does indeed work.....



I'm CosmoKramer, and I approve this message.
 
Question
Why dont you alter the background colour of the textbox on your Report

Hope this helps
Hymn
 
CosomoKramer,

No matter how I fiddle with it, txtPeachBox still only captures the height of dtmDuration set at design time, but not at run time, after it's grown.

hymn:
I didn't change the backcolor property of the original textbox(dtmDuration) as I need the color to span the width of the section. The other box is as wide as the section itself, and I need it's heigh to match the dtmDuration when it grows.

Would be just as grateful to get this to work with a rectangle behind these other controls, but tried a textbox because of the "can grow" thing.

Thanks to you both, I will keep working on it,
TWD
 
got it
you will need to change sizes and colors to suit

Code:
   Dim X1 As Single, Y1 As Single
    Dim X2 As Single, Y2 As Single
    Dim Offset As Single
    Dim Offset1 As Single
    Dim Color As Long
    'Dim Fillcolor As Long

    'Specify unit of measurement for coordinates on a page.
    Me.ScaleMode = 1        'Twips (1440 twips = 1 inch).

    'Define an offset of 1/8 inch from the text box to the rectangle.
    Offset = 1440 / 12
    Offset1 = 1440 / 2

    'X and Y coordinates for the top left corner of the box.
    X1 = Me![Surname].Left - Offset1
    Y1 = Me![Surname].Top - Offset

    'X and Y coordinates for the bottom right corner of the box.
    X2 = Me![Surname].Left + Me![Surname].Width + Offset1
    Y2 = Me![Surname].Top + Me![Surname].Height + Offset

    Me.DrawWidth = 3        'Width of the line (in pixels).

    Color = RGB(255, 0, 0)    'Use black line color.
 [b]   Fillcolor = RGB(0, 0, 255)
    FillStyle = 0  [/b]
    'Draw the rectangle with the Line method.
    Me.Line (X1, Y1)-(X2, Y2), Color, B

Hope this helps
Hymn
 
hymn,

Thank you, thank you, thank you for your help.

With some modification I was able to get this to work as I want.

Here's a star for you.

TWD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top