Resize one control to match the height of another Version: 2003(11.0)

  • Thread starter Thread starter keaven
  • Start date Start date
K

keaven

I have a report where there are two CanGrow controls, ProbTitle and
Staff_Comments. I also have three boxes (Vote_A, _B, and _C) which need
to grow to match the height of the longer of the two CanGrow controls.

Here is my (non-working) code that I put in the Detail's OnFormat event:

Code:

' Makes boxes fill entire height of row... or not.
If Me![ProbTitle].Height < Me![Staff_Comments].Height Then
Me![Vote_A].Height = Me![Staff_Comments].Height
Me![Vote_B].Height = Me![Staff_Comments].Height
Me![Vote_C].Height = Me![Staff_Comments].Height
Else
Me![Vote_A].Height = Me![ProbTitle].Height
Me![Vote_B].Height = Me![ProbTitle].Height
Me![Vote_C].Height = Me![ProbTitle].Height
End If


The problem is that Access doesn't know the height of the controls until
the OnPrint event, but you can't set the height of a control in the
OnPrint event.

I remember reading something about processing a report twice in order
for calculated sizes to be known, but i have no idea how to implement
something like that, if its even do-able. Is there any other way for me
to handle this?

-keaven


--
-----------------------------------------------------------------------
Keaven Freeman "There's no place like 127.0.0.1"
usenet[@]keaven[.]com ICQ: 35133457
http://www.keaven.com IM: KeavenMJ
"The box said 'Requires Windows 95 or better' ... so I installed Linux"
-----------------------------------------------------------------------
 
keaven said:
I have a report where there are two CanGrow controls, ProbTitle and
Staff_Comments. I also have three boxes (Vote_A, _B, and _C) which need
to grow to match the height of the longer of the two CanGrow controls.
[snip code that can't work]

The problem is that Access doesn't know the height of the controls until
the OnPrint event, but you can't set the height of a control in the
OnPrint event.

I remember reading something about processing a report twice in order
for calculated sizes to be known, but i have no idea how to implement
something like that, if its even do-able. Is there any other way for me
to handle this?


Are you sure that you really careabout making the controls
the same height? Isn't really a question of making the
lines around the controls the same size? If so, then you
can make the control's BorderStyle transparent and use code
(Line method) to draw rectangles in the Print event when you
do know the height of the tallest CanGrow text box.

There's a complete solution for this issue using the
PrintLines sample mdb at www.lebans.com
 
Unfortunately, yes, the controls so have to be the same height. I apply
conditional shading to the controls that aren't growing. I have tried
using lines as you suggested, and i can get that to work... but then the
shading only applies to the control, which is still only half as tall.
I need the whole area to grow so the shading covers the whole area.

-keaven


Marshall said:
Are you sure that you really careabout making the controls
the same height? Isn't really a question of making the
lines around the controls the same size? If so, then you
can make the control's BorderStyle transparent and use code
(Line method) to draw rectangles in the Print event when you
do know the height of the tallest CanGrow text box.

There's a complete solution for this issue using the
PrintLines sample mdb at www.lebans.com

--
-----------------------------------------------------------------------
Keaven Freeman "There's no place like 127.0.0.1"
usenet[@]keaven[.]com ICQ: 35133457
http://www.keaven.com IM: KeavenMJ
"The box said 'Requires Windows 95 or better' ... so I installed Linux"
-----------------------------------------------------------------------
 
The Line method allows you to specify the rectangle's fill
color. Wouldn't this take care of that requirement? I hope
it will, because I don't think there is another way.

Me.Line (Me.txtBox.Left, Me.txtBox.Top) - _
Step(Me.txtBox.Width, Me.Height), _
Me.txtBox.BackColor, BF
Me.Line (Me.txtBox.Left, Me.txtBox.Top) - _
Step(Me.txtBox.Width, Me.Height), _
vbBlack, B
 
<gasp> .. i must say, i wasn't aware of that! i will try it out
immidietly. Thanks!

-keaven

Marshall said:
The Line method allows you to specify the rectangle's fill
color. Wouldn't this take care of that requirement? I hope
it will, because I don't think there is another way.

Me.Line (Me.txtBox.Left, Me.txtBox.Top) - _
Step(Me.txtBox.Width, Me.Height), _
Me.txtBox.BackColor, BF
Me.Line (Me.txtBox.Left, Me.txtBox.Top) - _
Step(Me.txtBox.Width, Me.Height), _
vbBlack, B

--
-----------------------------------------------------------------------
Keaven Freeman "There's no place like 127.0.0.1"
usenet[@]keaven[.]com ICQ: 35133457
http://www.keaven.com IM: KeavenMJ
"The box said 'Requires Windows 95 or better' ... so I installed Linux"
-----------------------------------------------------------------------
 
Back
Top