How to draw a vertical line in subreport

C

Coderz

The code below perfectly work if it is not located inside a subreport.

Public Sub Report_Page()
Dim X1, Y1, X2, Y2 As Single
Me.DrawStyle = 0 ' a solid line

Me.DrawWidth = 1 ' set the thickness of the line

' Set the coordinates and draw a line down the middle of the page.

X1 = 60 'Int(Me.ScaleWidth / 2) ' find the middle of the page
Y1 = Me.Section(1).Height ' start just below the page header
X2 = X1 ' the line is vertical

' length of line is the length of the Page - (Height of the
PageHeader + Height of the Page Footer).

Y2 = Me.ScaleHeight

Me.Line (X1, Y1)-(X2, Y2) ' This draws the line
Me.Line (955, Y1)-(955, Y2) ' This draws the line
Me.Line (1740, Y1)-(1740, Y2) ' This draws the line
Me.Line (3360, Y1)-(3360, Y2) ' This draws the line
Me.Line (4560, Y1)-(4560, Y2) ' This draws the line
Me.Line (5940, Y1)-(5940, Y2) ' This draws the line
Me.Line (7850, Y1)-(7850, Y2) ' This draws the line
Me.Line (9050, Y1)-(9050, Y2) ' This draws the line
Me.Line (10020, Y1)-(10020, Y2) ' This draws the line
Me.Line (11460, Y1)-(11460, Y2) ' This draws the line
End Sub

This is code is not executed if under a subreport.

How could I execute it? I tried to call it like Call
Me.[Service_Record_Details].Report.Report_Page but it gives an error.
 
D

Damon Heron

Report_Page is actually a property of the report. In properties for the
report, look at Event, On Page.
Paste your code there (deleting the Public statement and end sub, and when
report opens, you will have your lines.

Damon
 
D

Damon Heron

I just realized what you are saying - you want the lines on the subreport.
Sorry. But, if
you put the code on the main reports Report_Page property, the lines will be
drawn thru
your subreport. This may require some repositioning of controls to align
the sections,
but it will work.

Damon

Damon Heron said:
Report_Page is actually a property of the report. In properties for the
report, look at Event, On Page.
Paste your code there (deleting the Public statement and end sub, and when
report opens, you will have your lines.

Damon

Coderz said:
The code below perfectly work if it is not located inside a subreport.

Public Sub Report_Page()
Dim X1, Y1, X2, Y2 As Single
Me.DrawStyle = 0 ' a solid line

Me.DrawWidth = 1 ' set the thickness of the line

' Set the coordinates and draw a line down the middle of the page.

X1 = 60 'Int(Me.ScaleWidth / 2) ' find the middle of the page
Y1 = Me.Section(1).Height ' start just below the page header
X2 = X1 ' the line is vertical

' length of line is the length of the Page - (Height of the
PageHeader + Height of the Page Footer).

Y2 = Me.ScaleHeight

Me.Line (X1, Y1)-(X2, Y2) ' This draws the line
Me.Line (955, Y1)-(955, Y2) ' This draws the line
Me.Line (1740, Y1)-(1740, Y2) ' This draws the line
Me.Line (3360, Y1)-(3360, Y2) ' This draws the line
Me.Line (4560, Y1)-(4560, Y2) ' This draws the line
Me.Line (5940, Y1)-(5940, Y2) ' This draws the line
Me.Line (7850, Y1)-(7850, Y2) ' This draws the line
Me.Line (9050, Y1)-(9050, Y2) ' This draws the line
Me.Line (10020, Y1)-(10020, Y2) ' This draws the line
Me.Line (11460, Y1)-(11460, Y2) ' This draws the line
End Sub

This is code is not executed if under a subreport.

How could I execute it? I tried to call it like Call
Me.[Service_Record_Details].Report.Report_Page but it gives an error.
 
B

Bruce Kovacs

I have used the following code in a subreport, and it works fine. The
numbers for the horizontal values were entered manually (trial and error) to
cause the lines to align with the edges of the controls on the subreport.

Private Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)
On Error Resume Next
Dim MyDetailHeight As Single
MyDetailHeight = Me.Section(acDetail).Height

Me.ScaleMode = 7
Me.Line (5.101, 0)-(5.101, MyDetailHeight)
Me.Line (5.94, 0)-(5.94, MyDetailHeight)
Me.Line (6.801, 0)-(6.801, MyDetailHeight)
Me.Line (8.1, 0)-(8.1, MyDetailHeight)

End Sub


Damon Heron said:
I just realized what you are saying - you want the lines on the subreport.
Sorry. But, if
you put the code on the main reports Report_Page property, the lines will be
drawn thru
your subreport. This may require some repositioning of controls to align
the sections,
but it will work.

Damon

Damon Heron said:
Report_Page is actually a property of the report. In properties for the
report, look at Event, On Page.
Paste your code there (deleting the Public statement and end sub, and when
report opens, you will have your lines.

Damon

Coderz said:
The code below perfectly work if it is not located inside a subreport.

Public Sub Report_Page()
Dim X1, Y1, X2, Y2 As Single
Me.DrawStyle = 0 ' a solid line

Me.DrawWidth = 1 ' set the thickness of the line

' Set the coordinates and draw a line down the middle of the page.

X1 = 60 'Int(Me.ScaleWidth / 2) ' find the middle of the page
Y1 = Me.Section(1).Height ' start just below the page header
X2 = X1 ' the line is vertical

' length of line is the length of the Page - (Height of the
PageHeader + Height of the Page Footer).

Y2 = Me.ScaleHeight

Me.Line (X1, Y1)-(X2, Y2) ' This draws the line
Me.Line (955, Y1)-(955, Y2) ' This draws the line
Me.Line (1740, Y1)-(1740, Y2) ' This draws the line
Me.Line (3360, Y1)-(3360, Y2) ' This draws the line
Me.Line (4560, Y1)-(4560, Y2) ' This draws the line
Me.Line (5940, Y1)-(5940, Y2) ' This draws the line
Me.Line (7850, Y1)-(7850, Y2) ' This draws the line
Me.Line (9050, Y1)-(9050, Y2) ' This draws the line
Me.Line (10020, Y1)-(10020, Y2) ' This draws the line
Me.Line (11460, Y1)-(11460, Y2) ' This draws the line
End Sub

This is code is not executed if under a subreport.

How could I execute it? I tried to call it like Call
Me.[Service_Record_Details].Report.Report_Page but it gives an error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top