Repost: Adjust height of control

D

Daniel

Hello,

I'm generating a table in which the controls can grow to adjust to the
content of the information. Because there are five textboxes that
constitute
the table, I would like them to all have the height of the biggest control
per line in the table ( so that it is linear).

How can I achieve this? When I place my code in the On Print event I get an
error 2191 "you can't set the height property after printing has started"

Here the code I was trying to get to work:
On Error GoTo Error

Dim lngHeight As Long 'store the height of tallest control
Dim i, j As Integer
Dim lngLeft As Long
lngHeight = 0 'initialize the counter

'compare heights and determines the maximum height needed
For i = 1 To 5
If Me("Text" & i).Height > lngHeight Then
lngHeight = Me("Text" & i).Height 'stores maximum height
End If
Next

'Change the height of the cells to match that of the maximum height
For j = 1 To 5
Me("Text" & j).Height = lngHeight
Next

Exit_Error:
Exit Sub

Error:
MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf &
"Error Number: " & Err.Number & vbCrLf & "Error Description: " &
Err.Description, vbCritical, "An Error has Occured!" '*** explain the
error
that occured and exit the sub
Resume Exit_Error

Thanks,

Daniel
 
M

Marshall Barton

Daniel said:
I'm generating a table in which the controls can grow to adjust to the
content of the information. Because there are five textboxes that
constitute
the table, I would like them to all have the height of the biggest control
per line in the table ( so that it is linear).

How can I achieve this? When I place my code in the On Print event I get an
error 2191 "you can't set the height property after printing has started"


You don't really need to change the height of the controls.
You only need to get their border lines to line up.

For a generic solution to this issue, see the PrintLines
download at www.lebans.com
 
D

Duane Hookom

I sent Daniel to Lebans the first time he posted this question.

If there are questions about the PrintLines solution then ask them in the
original thread.
 
D

Daniel

Duane,

Didn't mean to double up on the question, but I had posted it in the
wrong groups... Just wanted to place it in the right place...

Sorry about the confusion... For anyone who is following the original
message was in the programming newsgroup.

Daniel

Duane Hookom said:
I sent Daniel to Lebans the first time he posted this question.

If there are questions about the PrintLines solution then ask them in the
original thread.

--
Duane Hookom
MS Access MVP


get
 
D

Daniel

Marshall,

In past reports I have done as you have posted in your reponse and used code
to draw lines to made a table. However, in this specific case, I am
required to highlight each row based on criteria. The fact that the cells
do not have the same heights makes the highlighting jagged (just looks bad).
The solution, at least in my mind (feel free to correct me), is to ensure
all the cells in a row have the same high thus the highlighting will appear
proper. If you know how I can achieve this or have another idea... drop me
a line!

Thanks for your time,

Daniel
 
M

Marshall Barton

Daniel said:
In past reports I have done as you have posted in your reponse and used code
to draw lines to made a table. However, in this specific case, I am
required to highlight each row based on criteria. The fact that the cells
do not have the same heights makes the highlighting jagged (just looks bad).
The solution, at least in my mind (feel free to correct me), is to ensure
all the cells in a row have the same high thus the highlighting will appear
proper. If you know how I can achieve this or have another idea... drop me
a line!


The entire detail section? If yes, then make all the
controls BackStyle Transparent.

You can then just set the section's BackColor.

Another way is to draw rectangle with the desired fill
color.

Yet another way, is to add a Rectangle control behind the
other controls and set its BackColor.



 
D

Daniel

Marshall,

Thank you for the quick tips! I'll try them out and see if I can make them
work.

Daniel
 
M

Marshall Barton

I take it you do want to color the entire detail?

Setting the section's BackColor is clearly the easiest and
most common approach.

I was pretty skimpy on details for the other techniques. If
you need additional help with them, post back.
 
D

Daniel

Marshall,

Sorry it took me a while to get back to you, but it work just perfectly.
Thanks!

Daniel

Marshall Barton said:
I take it you do want to color the entire detail?

Setting the section's BackColor is clearly the easiest and
most common approach.

I was pretty skimpy on details for the other techniques. If
you need additional help with them, post back.
--
Marsh
MVP [MS Access]


Thank you for the quick tips! I'll try them out and see if I can make them
work.
used
code drop
me
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top