Public Function basVarBox(Form As String, ULCtrl As String, LRCtrl As String) As String
'Michael Red, 12/1/2001
'Draw a "Box" around a group of controls in a Report
'where the controls' Properties CanGrow and CanShrink may be TRUE
'NOTE: The two controls "Should" form a "Box w/o any OTHER controls
'overlapping the boarder.
Dim X1 As Double 'Left
Dim Y1 As Double 'Top
Dim X2 As Double 'Right
Dim Y2 As Double 'Bottom
Dim Offset As Long 'Border / Whitspace Width
Dim LnColor As Double 'Line color to Draw
Dim tmpXY(1) As Double 'Temp To check MinMax of X | Y Point
'Must be CALED from OnPrint Event of Report. Similar to:
'Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
' MyCoords = basVarBox(Me.name, Expression.name, Text1.name)
'End Sub
'Where:
' MyCoords is a Dummy (String) variable
' Me.Name is a constant (returns the Name of the REPORT)
' Expression(.Name) is the "name" of one of the two Controls. and
' Text1(.Name) is the "name" of the other control
'Left X (Min of Left of the Controls)
tmpXY(0) = Reports(Form).Controls(ULCtrl).Left
tmpXY(1) = Reports(Form).Controls(LRCtrl).Left
If (tmpXY(0) < tmpXY(1)) Then
X1 = tmpXY(0)
Else
X1 = tmpXY(1)
End If
X1 = X1 - Offset
'Right X (Max of Left + Width of the Controls)
tmpXY(0) = Reports(Form).Controls(ULCtrl).Left + Reports(Form).Controls(ULCtrl).Width
tmpXY(1) = Reports(Form).Controls(LRCtrl).Left + Reports(Form).Controls(LRCtrl).Width
If (tmpXY(0) > tmpXY(1)) Then
X2 = tmpXY(0)
Else
X2 = tmpXY(1)
End If
X2 = X2 + Offset
'Top Y (Min of Top of the Controls)
tmpXY(0) = Reports(Form).Controls(ULCtrl).Top
tmpXY(1) = Reports(Form).Controls(LRCtrl).Top
If (tmpXY(0) < tmpXY(1)) Then
Y1 = tmpXY(0)
Else
Y1 = tmpXY(1)
End If
Y1 = Y1 - Offset
'Bottom Y (Max of Top + Height of the Controls)
tmpXY(0) = Reports(Form).Controls(ULCtrl).Top + Reports(Form).Controls(ULCtrl).height
tmpXY(1) = Reports(Form).Controls(LRCtrl).Top + Reports(Form).Controls(LRCtrl).height
If (tmpXY(0) > tmpXY(1)) Then
Y2 = tmpXY(0)
Else
Y2 = tmpXY(1)
End If
Y2 = Y2 + Offset
Reports(Form).Line (X1, Y1)-(X2, Y2), LnColor, B
End Function