Todd:
Firstly, just to be clear that, in the context of Fred's response, we are
singing from the same hymn sheet, I'm assuming it’s the boxes around the
controls you want to grow to the same height as the tallest in each row,
right? That's what the code does.
1. Me.Section(0).Controls refers to the Controls collection of the report's
Detail section. You could also refer to it using the built in acDetail
constant with Me.Section(acDetail).Controls. This allows the code to lop
through each control in the section and draw a box around them. In the code
as written it assumes every control will be 'boxed', but you might in some
circumstances only want only text boxes to be 'boxed', excluding labels for
instance, in which case you could amend the code so it skips all but text
boxes:
Option Compare Database
Option Explicit
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
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(acDetail).Controls
If C.Height > lngHeight Then
lngHeight = C.Height
End If
Next C
If PrintCount = 1 Then
' Draw the box around the record
For Each C In Me.Section(acDetail).Controls
If C.ControlType = acTextBox Then
X1 = C.Left
X2 = C.Left + C.Width
Y1 = C.Top
' add twenty twips at bottom to
' avoid tight cropping to text
Y2 = lngHeight + 20
Me.Line (X1, Y1)-(X2, Y2), vbBlack, B
End If
Next C
End If
End Sub
You'll have noticed that I've also removed the DrawLine procedure and the
line calling it from the above. That in fact draws a continuous vertical
line down the page between two controls, so is not something you need.
2. Me.Line calls the Line method of the report object. This draws a line
or a box on the report at the co-ordinates specified The first two in
parentheses (X1, Y1) specify where the box starts at the top left position,
and the second two (X2, Y2) where it ends at the bottom right position.
Ken Sheridan
Stafford, England
Todd C said:
Hey thanks Ken. Now for the more in depth question. Im pretty savvy with
coding, of course that only because I have used the code at one time or
another. This code however, I have never tried, so......
I pretty much understand it. There are just a few I do not.
Me.Section(0).Controls. ?
Me.Line ?
If I named one of my boxes "BXDivision", where would I put that in the code.
Now since I have about 12 Boxes that all need to change, where in the code
would I put them? Ill be playing around with it, just to understand it more,
but I would appreciate the help. Makes things go a little faster.
Thanks again Ken.