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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vary line length to match a field that 'can grow' in a report?

Status
Not open for further replies.

steveroot

IS-IT--Management
Dec 29, 2000
20
GB
Hi, I have a report which shows quantity, description and price (all in detail section) . Quantity and description fields are always .5cm high, but the description field changes height according to how much description there is. EG, one line may be 3cm high, the next .5cm, next 1.5cm etc.

I want there to be vertical lines between the qty / desc / price fields.

Unfortuntately, I can't find a way of having these vertical lines show across the whole detail section. Does anyone know a way to make the vertical lines 'grow' according to the height of the description field please? --
Steve Root
 
I found this out on the web somewhere, sometime ago, and I don't know who to give credit to. I haven't tried this so let me know how it works.

------------ start of copy

Q:peter Massey is looking for a way to print vertical lines on a report that will adjust in size (vertically) to match the size of a text box set to grow if necessary (CanGrow is set to True).
A:This can be done with the antique Line method, left over from the earliest versions of Basic. This is the hard way to draw a line on a report, and can be painfully slow in operation, but here is an example I prepared a while back that draws a bright green line next to an adjustable-height textbox (the code is a Print event procedure for the report?s Detail section):
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim sngKeyWordsTop As Single
Dim sngKeyWordsLeft As Single
Dim sngKeyWordsHeight As Single
Dim sngKeyWordsBottom As Single
sngKeyWordsTop = Me![txtTopicKeyWords].Top
sngKeyWordsHeight = Me![txtTopicKeyWords].Height
sngKeyWordsLeft = 1650
sngKeyWordsBottom = sngKeyWordsTop + Me![txtTopicKeyWords].Height
Me.DrawStyle = 6
Me.DrawWidth = 12
Me.Line (sngKeyWordsLeft, sngKeyWordsTop)- _
(sngKeyWordsLeft, sngKeyWordsBottom), RGB(0, 255, 0)
End Sub
This code was written for Access 2.0, but it still works in Access 97 and Access 2000.

-------------------- end of copy

PaulF
 
paste this in the detail section under the event On Print
====================================
Public Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Me.ScaleMode = 1
Me.ForeColor = 0

'Repeat the following line of code for each vertical line
'1 * 1440 represents 1 inch.

Me.Line (0# * 1440, 0)-(0# * 1440, 14400) 'location of first line
Me.Line (0.4583 * 1440, 0)-(0.4583 * 1440, 14400) 'location of second line
Me.Line (0.9583 * 1440, 0)-(0.9583 * 1440, 14400) 'etc
Me.Line (1.5833 * 1440, 0)-(1.5833 * 1440, 14400)
Me.Line (4.9167 * 1440, 0)-(4.9167 * 1440, 14400)
Me.Line (5.9167 * 1440, 0)-(5.9167 * 1440, 14400)
Me.Line (6.9167 * 1440, 0)-(6.9167 * 1440, 14400)
Me.Line (7.9583 * 1440, 0)-(7.9583 * 1440, 14400) ' last line

'The 14400 is an arbitrary number to increase the line
'to the max of a section.
End Sub

====================================
You'll have to find out where your lines are at. For example, line 2 (second vertical line from the left) is at 0.4583.

I got this from Microsoft. You can do a search for Vertical Lines there too.

Hope this Helps
 
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