How to Create multiple vertical lines that grow in the detail section of a report

John Lee

Member
Local time
Today, 08:00
Joined
Dec 1, 2024
Messages
51
Hi I'm looking to write some code that will produce a vertical line in the detail section of a report.

I have the following code written in the on page event of my report:

Start Code:

Dim lngReportDetailHeight as long

lngReportDetailHeight = Me.Section(3).Height
Me.Line (0, lngReportDetailHeight)-(0,32767)

End Code

This code draws a line down the left hand side within the detail section of the report which is what I want, only it's to far to the left and I need it to be slightly more to the right.

I also need to be able reproduce this line multiple times but against each of the columns of data in my report, please attached screen shot of my report, you can see the dividing lines in the column headers, which is what I would like to achieve in the detailed section of the report.

Any assistance would be greatly appreciated.
 

Attachments

  • Screenshot of Report.jpg
    Screenshot of Report.jpg
    168.6 KB · Views: 20
Try this code in the Detail_Print Section. It draws 3 different vertical lines.
In this example you have to set the LeftPosition value in TWIPS.
Code:
    Dim LeftPosition As Single
    Const MAX_HEIGHT_SIZE  As Single = 32767 ' This limit correspond to the section’s actual rendered height, not control properties.
 
    LeftPosition = 2000
    Me.Line (LeftPosition, 0)-(LeftPosition, MAX_HEIGHT_SIZE)
 
    LeftPosition = 4000
    Me.Line (LeftPosition, 0)-(LeftPosition, MAX_HEIGHT_SIZE)
 
    LeftPosition = 6000
    Me.Line (LeftPosition, 0)-(LeftPosition, MAX_HEIGHT_SIZE)
1768734344503.png
 
Last edited:
Hi I'm looking to write some code that will produce a vertical line in the detail section of a report.

I have the following code written in the on page event of my report:

Start Code:

Dim lngReportDetailHeight as long

lngReportDetailHeight = Me.Section(3).Height
Me.Line (0, lngReportDetailHeight)-(0,32767)

End Code

This code draws a line down the left hand side within the detail section of the report which is what I want, only it's to far to the left and I need it to be slightly more to the right.

I also need to be able reproduce this line multiple times but against each of the columns of data in my report, please attached screen shot of my report, you can see the dividing lines in the column headers, which is what I would like to achieve in the detailed section of the report.

Any assistance would be greatly appreciated.
Hi, Thank you

For your assistance, I've been able to create the additional lines, however they extend right to the top and the bottom of the report, I only need them to extend to the bottom of the column headers in red (white text) and not beyond the bottom of the detail section, any help with that would be most appreciated, please see screen shot.
 

Attachments

  • Report Screen Shot after update of code.jpg
    Report Screen Shot after update of code.jpg
    176.2 KB · Views: 16
Oh, and here is the amended code:

Code starts:
Private Sub Report_Page()

Dim lngReportDetailHeight As Long
Dim LeftPosition As Single

lngReportDetailHeight = Me.Section(3).Height

Const Max_Height_Size As Single = 11000

LeftPosition = 185
Me.Line (LeftPosition, 0)-(LeftPosition, Max_Height_Size)

LeftPosition = 2100
Me.Line (LeftPosition, 0)-(LeftPosition, Max_Height_Size)

LeftPosition = 4100
Me.Line (LeftPosition, o)-(LeftPosition, Max_Height_Size)

LeftPosition = 6700
Me.Line (LeftPosition, 0)-(LeftPosition, Max_Height_Size)

LeftPosition = 9350
Me.Line (LeftPosition, 0)-(LeftPosition, Max_Height_Size)

LeftPosition = 11970
Me.Line (LeftPosition, 0)-(LeftPosition, Max_Height_Size)

LeftPosition = 14010
Me.Line (LeftPosition, 0)-(LeftPosition, Max_Height_Size)

LeftPosition = 15960
Me.Line (LeftPosition, 0)-(LeftPosition, Max_Height_Size)

End Sub

Code Ends

I've just commented out the following lines and I'm still getting the same result.

''Dim lngReportDetailHeight As Single
''lngReportDetailHeight = Me.Section(3).Height

Any suggestions appreciated
 
Last edited:
Hi, Thank you

For your assistance, I've been able to create the additional lines, however they extend right to the top and the bottom of the report, I only need them to extend to the bottom of the column headers in red (white text) and not beyond the bottom of the detail section, any help with that would be most apreciables, please see screen shot.
I think you have the code in the page section instead of in the detail section.
 
that is hard coding your line positions, requiring a recode if you resize/reposition your controls

Perhaps try something like

Code:
'identify header row '(assumes header labels are aligned top)'
dim ctl as control
dim hdrTop as long
dim hdrRight as long

for each ctl in me.header
    if ctl.controltype=aclabel then
      if ctl.top>hdrTop then hdrTop=ctl.top
     
    end if
next ctl

'parse the header row
for each ctl in me.header
    if ctl.controltype=aclabel and ctl.Top=hdrTop then
      Me.Line (ctl.left, 0)-(ctl.left, Max_Height_Size)
      if ctl.left+ctl.width>hdrRight and hdrTop=ctl.top then hdrRight=ctl.left+ctl.width
    end if
next ctl

'add rightmost line
Me.Line (hdrRight, 0)-(hdrRight, Max_Height_Size)
 
Last edited:

Users who are viewing this thread

Back
Top Bottom