Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a growing/shrinking rectangle Box in a report

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I would like to encapsulate 6 fields in a sub report (that are set to grow and shrink) with a rectangle box (just the outline -- it is set to transparent). Can i set the rectangle box to grow and shrink to the the dimensions of the 6 fields that i want the rectangle to surround? How?

Thank you
 
Code:
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

Perhaps a bit closer, as it actually does the var box. As ALWAYS, the trimmings (error checking ... ) are left to YOUR discretion. MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top