Keeping rows in a report the same size

J

judyg73

I have a report that has 4 fields in a row. One of the fields is a memo
field. Sometimes there will be lengthy information in the memo field and
sometimes there will be nothing in the memo field. I want each field in the
row to be the same size as the memo field. Can this be done?
 
F

fredg

I have a report that has 4 fields in a row. One of the fields is a memo
field. Sometimes there will be lengthy information in the memo field and
sometimes there will be nothing in the memo field. I want each field in the
row to be the same size as the memo field. Can this be done?

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 the Memo field's CanGrow property to Yes.
Set the Memo field's CanShrink property to No.
Size all of the controls to the same Height.

Place the following code in 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
 
J

judyg73

Just exactly what I needed - thanks!

fredg said:
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 the Memo field's CanGrow property to Yes.
Set the Memo field's CanShrink property to No.
Size all of the controls to the same Height.

Place the following code in 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
 
J

judyg73

This is working for a one page report, but what do I need to do if the report
carries over to 2 pages and I also have a sub report attached?
 

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