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

LINE LENGTH 2

Status
Not open for further replies.

mustangirl

Programmer
Aug 16, 2001
27
US
I HAVE A REPORT WITH TWO SUBREPORTS ON THEM. I WANT A LINE TO SEPERATE THE TWO SUBREPORTS. THE SUBREPORTS AND THE DETAIL SECTION ARE SET UP TO GROW AND SHRINK. HOWEVER, HOW DO I GET THE LINE TO ADJUST TO THE HIEGHT OF THE DETAIL SECTION EACH TIME.

SOMETHING IN CODE BUILDER SUCH AS
LINE17.HEIGHT = DETAILSECTION.HEIGHT
I KNOW THAT IS WAY OFF, BUT WHAT WOULD THE CORRECT CODE BE? SHAWNDRA CREE JONES,
DATABASE DEVELOPER
TOYOTA MOTOR MANUFACTURING NORTH AMERICA
ERLANGER, KY
 
AFAIK, there is no way to get the "dynamic" height of anyobject in Ms. A. Any 'computation' returns the design parameters for Height and width.

Still, I don't quite understand your 'problem'. A line placed just above the section break should always appear at the bottom of the section. If the section is repeated, ALL of the section's controls should repeat -oncluding the line to denote the detail item.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
I WANT A VERTICAL LINE FROM TOP OF DETAIL SECTION TO THE BOTTOM OF DETAIL SECTION. IN THE DETAIL SECTION I HAVE TWO SUB REPORTS THAT VARY IN SIZE FROM TOP TO BOTTOM. THEY SHRINK AND EXPAND ON EACH DETAIL SECTION. I NEED A LINE ON THE DETAIL SECTION OF THE MAIN REPORT, THAT WILL SHRINK AND EXPAND ALONG WITH IT. SHAWNDRA CREE JONES,
DATABASE DEVELOPER
TOYOTA MOTOR MANUFACTURING NORTH AMERICA
ERLANGER, KY
 
Oh. Vertiaclly. Sorry, I simply glossed over that detail.

Double sorry. (AFAIK) can't be done. Again, NO way to get the DYNAMIC (current instantaneous) Height or Width property of objects (Forms, controls, reports, sections ...).

If you find a way -PLEASE- let me (and the rest of the VB world) know HOW!

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
I have done this with subreports.
You need to code in the Print Event and create a line dynamically. You use the Line method.

Here is some code from my report. My subreports are side by side and are usually not the same size. This is tough to read.

' box for sub reports
' new left line of field
Me.Line (Me.txtLevel_Stmnt.Left - 25, 0)-((Me.txtLevel_Stmnt.Left - 25), (Me.Child37.Height + Me.Child37.Top + 35)), RGB(0, 0, 0)
' new right line of field 1
Me.Line (Me.Child37.Left + Me.Child37.Width + 25, Me.Child37.Top)-((Me.Child37.Left + Me.Child37.Width + 25), (Me.Child37.Height + Me.Child37.Top + 35)), RGB(0, 0, 0)
' new right line of field 2
Me.Line (Me.Child35.Left + Me.Child35.Width + 25, Me.Child35.Top)-((Me.Child35.Left + Me.Child35.Width + 25), (Me.Child37.Height + Me.Child37.Top + 35)), RGB(0, 0, 0)


NOTE: Me.Child37 is the subreport on the left hand side.
Me.Child35 is the subreport on the right hand side.
The Me.txtLevel_Stmnt is a text box I use for a heading.

I hope this helps.

John
 
THAT SOUNDS GREAT. I WILL GIVE IT A WHIRL!!! SHAWNDRA CREE JONES,
DATABASE DEVELOPER
TOYOTA MOTOR MANUFACTURING NORTH AMERICA
ERLANGER, KY
 
Hmmmmmmmmmm,

Never stop being taught "new" (to me) features.

Thanks (and kudos) to JohnLowell.

Being a creature of laziness, I reviewed and generalized his code - using the secrete ingreedient of OnPrint knows the 'rendered Height' of the objects!

While the TRULY lazy would reduce these to a single function, I chose to provide seperate routines for the Single line and the BOX.

The single line control ONLY provides for vertical lines in on the report, and has the option of placing the line to the LEFT or RIGHT of the specified control.

The Box routine requires two (2) controls, and palaces a box around the "out side" of them, using their collective extreme locations.

Further, each routine may (SHOULD) be placed in a general module, so there is no need to copy the functions (procedures) for each report, or to modiify the routine for different controls on the report(s).

This one draws a box around the controls
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
[code]


This one does JUST a vertical Line
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 &quot;name&quot; 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
[/code] MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Thanks Michael! That function works great for what I am trying to do, but with one exception. I am printing a report of a few variables across one line. The report sort of looks like this:

Work Order: Tech: Job Description:
13 Amy Repair cd-rom
14 John Install software



I am trying to box all of the work orders for a certain client. I am using your function above for the vertical lines, which works perfectly for my line on the right (to the right of txtJobDesc). However, I can't get the line on the left (to the left of txtWorkOrder) to output correctly.

The problem occurs when the text for Job Description runs over to two lines. The textbox will automatically grow to accomodate the text. The text box with the work order (on the left) does not increase in height and so the line on the left is always shorter than the line on the right, producing gaps every once in a while.

I have tried to create a dummy textbox that will pull from the same field in the database as txtJobDesc, so it will be the same height. I want to draw the line on the left with that and then clear out the contents of that field, so the text does not display again. I have tried to make the text white, so it won't be seen, I have tried to use the code: txtDummy.text=&quot;&quot;, but that doesn't work either. Any ideas? Thanks so much!

 
I figured out how to get it to display the line on the left, however, now I'm having issues when I go to print the form. The line on the left prints fine, but the line on the right doesn't print at all. I'm pretty sure the textbox isn't expanding too wide so that it would be falling off of the page, but I'm not sure why it won't print. It displays perfectly on the screen. Any ideas?
 
use the basVarBox routine to draw boxes areount the elements (Columns)?

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Thanks John and Michael !
I had the same problem - a user wanting vertical lines, just like Excel (oh boy)

playing with the solution above, you can even generalize further. I had striker73's problem: I wanted to draw a line separating all columns that would be the height of the control with the most growth.

the real issue is you have design time height of controls, yet you want rendered height. by referencing the controls from the report's control collection rather than the control directly, you get the rendered height. the real simple syntax is reportname.CONTROLS(control.NAME).HEIGHT

with that you can draw lines anywhere simply....
 
Yes, but the general issue is that you want the height of the DETAIL SECTION, not the height of any specific element (eontrol / object) of the section.

The overall process above really only works in the sense of a single 'row' of controls in the detail section, or (for the BOX soloution) for a group of controls to be 'isolated'.

There are any number of reports I have generated which have multiple (and even varying) numbers of rows for a single detail. These cause problems if any part of the detail is set to can grow/shrink.


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