adjust height of controls

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.

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
 
B

Brian

Daniel said:
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.

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

We are, I presume, talking reports here, in which case you may find that
what you want can be achieved by setting the "Can Grow" property to "Yes"
for the text boxes concerned, and also for the relevant report section(s)
e.g. the Detail section.
 

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