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!

Expanding Line objects to fill space

Status
Not open for further replies.

LittleSmudge

Programmer
Mar 18, 2002
2,848
GB
I am working on updating a database originally built by someone else. It contains reports where various fields in the detail section are separated by vertical LINE controls ( point size 2 so they are big and obvious )
One of the text controls in the report has it's CanGrow set to Yes and so occasionally the control grows to accommodate a lot of data and this means that the lines do not join up from one record to the next and we get an odd looking gap in what would otherwise be vertial lines running down the whole length of the page.

I've tried to get the Detail.Height value and set the Line.Height value to match it but
1) Detail.Height doesn't change in OnFormat even if the control is expanding it to fit ( Because it doesn't happen until OnPrint ? )

2) The Line control doesn't have a .Height property visible in VBA

3} I can't change Line.Height in the OnPrint event anyway because it has already been formatted ( - is this true ? )


Any ideas how I do what I need?


G LS
 
Ture? Not! On Print is the only useful event to change the line height! Try it - You'll LIke it!

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Tried it Michael

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If TextData.Height > 397 Then
Line9.Height = TextData.Height
End If

End Sub

BUT

1) Detail.Height doesn't change even in OnPrint
2) So I tried OffendingTextBox.Height and that changes so I detect the 'growth'
3) I then get an error 2191 "Can't set the height property after printing has started" error in response to trying to set the line height.



G LS
 
Review / revise the below. It does work. In this instance, it references the control height, so for it to do EXACTLY what you ask, the control would need to be the ONLY control w. "CanGrow" AND it would need to have it's "Top" Parameter set to 0.

Of course, many variations are possible, but this only requires that I write this (header) paragraph and copy / paste the procedure.

You could also have done a search on some of the keywords and found the routine on Tek-Tips, such as "Vertical Line" and variations.

Code:
Public Function BasVertLn(Form As String, MyCtrl As String, _
                          Optional LR As Boolean = True) As String

    'Michael Red, 12/1/2001
    'Draw a Vertical Line Beside a Controls on a Report
    'where the control's Properties CanGrow and CanShrink may be TRUE

    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

    Offset = 35

    '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, False) Lines to RIGHT
    'End Sub

'                               -OR-

    'Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    '    MyCoords = basVarBox(Me.name, Expression.name, True) Lines to LEFT
    '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 the Controls.

    'Left X  (Min of Left of the Control)
    X1 = Reports(Form).Controls(MyCtrl).Left
    X1 = X1 - Offset

    'Right X  (Max of Left + Width of the Controls)
    X2 = Reports(Form).Controls(MyCtrl).Left + Reports(Form).Controls(MyCtrl).Width
    X2 = X2 + Offset

    'Top Y  (Min of Top of the Controls)
    Y1 = Reports(Form).Controls(MyCtrl).Top
    Y1 = Y1 - Offset

    'Bottom Y (Max of Top + Height of the Controls)
    Y2 = Reports(Form).Controls(MyCtrl).Top + Reports(Form).Controls(MyCtrl).height
    Y2 = Y2 + Offset

    Select Case LR

        Case Is = True
            Reports(Form).Line (X1, Y1)-(X1, Y2), LnColor

        Case Is = False
            Reports(Form).Line (X2, Y1)-(X2, Y2), LnColor

    End Select

End Function


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