Variable Row Heights in reports?

N

Nate

I have a report that prints statements, detail section is in 4 columns. The
first column is the item description which is occasionally 3 lines deep, but
usually not more than 2. Each text box has a border, and there is no spare
space above or below the row of textboxes; so it prints as a grid.

Is there a way to grow all 4 boxes together. I can set the can grow
property on the first box, but the other three boxes do not grow, so the grid
effect is messed up. I could just run a line under the boxes (no box
borders), but I need the vertical lines still.

Is there a trick way of doing this that is easier than writing a pile of
code to resize the other boxes in the event that the first grows?
 
F

fredg

I have a report that prints statements, detail section is in 4 columns. The
first column is the item description which is occasionally 3 lines deep, but
usually not more than 2. Each text box has a border, and there is no spare
space above or below the row of textboxes; so it prints as a grid.

Is there a way to grow all 4 boxes together. I can set the can grow
property on the first box, but the other three boxes do not grow, so the grid
effect is messed up. I could just run a line under the boxes (no box
borders), but I need the vertical lines still.

Is there a trick way of doing this that is easier than writing a pile of
code to resize the other boxes in the event that the first grows?

You mean you wish to enclose each control in a box, sized to the
tallest control on that line?

In the Detail Section, set each control's Border property to
Transparent.
Set the Detail Section's CanGrow property to Yes.
Set each control's CanGrow property to Yes.
Size all of the controls to the same Height.
Position each control so the right side of one just touches the left
side of the next control on that row.

Copy and Paste the following code into the Report Detail Print event:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
' draws a box around each control,
' set to the height of the tallest control on that line.

Dim lngHeight As Long
Dim X1 As Single
Dim Y1 As Single
Dim Y2 As Single
Dim X2 As Single

Me.DrawStyle = 0

' Find the height of the tallest control in the row
Dim c As Control
For Each c In Me.Section(0).Controls
If c.Height > lngHeight Then
lngHeight = c.Height
End If
Next

' Draw the box around the record
For Each c In Me.Section(0).Controls
X1 = c.Left
X2 = c.Left + c.Width
Y1 = c.Top
Y2 = lngHeight
Me.Line (X1, Y1)-(X2, Y2), vbBlack, B
Next c

End Sub
 

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