Horizontal lines

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi. I'm using the rectangle tool to draw vertical lines, but I can't figure
out how to add to it to draw horiziontal lines as well. I'd appreciate your
help- Thanks.
 
Are you using Microsoft Access (a relational database program)? If so,
there is in the toolbox a line tool. If not, you are asking the question in
the wrong place.
 
Stephanie said:
Hi. I'm using the rectangle tool to draw vertical lines, but I can't figure
out how to add to it to draw horiziontal lines as well.


I don't understand. A rectangle consists of both horizontal
as well as vertical lines.

Just in case you missed it there is also a Line tool that
can be used to place a line at any angle.
 
Sorry for being cryptic. I can't use the line tool because lines drawn with
it don't export to RTF. So I need to use vba code to draw the lines.

Duane H. published code that I've used for vertical lines. I have
rectangles called Rect1 through Rect9. The code draws vertical lines from
the top, left-hand corner of the rectangles down from page header to footer.

But I can't seem to make horizontal lines with the code as well and would
appreciate coding help. Thanks:

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)- _
(intLeft, intLineBottom)
Next

On Error GoTo 0
Exit Sub

Report_Page_Error:
Select Case Err
Case 2462 'no page header
intPageHeadHeight = 0
Resume Next
End Select
MsgBox "Error " & Err.Number & " (" & _
Err.Description & ") in procedure " & _
"Report_Page of VBA Document Report_Report1"

End Sub
 
Stephanie said:
Sorry for being cryptic. I can't use the line tool because lines drawn with
it don't export to RTF. So I need to use vba code to draw the lines.

Duane H. published code that I've used for vertical lines. I have
rectangles called Rect1 through Rect9. The code draws vertical lines from
the top, left-hand corner of the rectangles down from page header to footer.

But I can't seem to make horizontal lines with the code as well and would
appreciate coding help. Thanks:

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)- _
(intLeft, intLineBottom)
Next

On Error GoTo 0
Exit Sub

Report_Page_Error:
Select Case Err
Case 2462 'no page header
intPageHeadHeight = 0
Resume Next
End Select
MsgBox "Error " & Err.Number & " (" & _
Err.Description & ") in procedure " & _
"Report_Page of VBA Document Report_Report1"

End Sub


You need to specify the right side of the rectangle. Perhaps
just:

intWidth = Me("Rect" & intRects).Width
. . .
Me.Line (intLeft,intTop)-(intLeft+intWidth,intLineBottom)

But I won't garantee that Word can handle these lines any
better than regular line controls.
 
Marsh,
Thanks for the reply. Actually I have exported to RTF using Stephen Lebans'
utility that embeds the output of Snapshot Format inside an RTF file and it
does show my vertical lines that were written using vba, but not those made
with the line drawing tool.

I tried your suggestion for horizontal lines but was only able to draw
double vertical lines. Basically, I want Rect1...Rect9 to draw only vertical
lines. And I'd like, say, Rect11 and Rect12 to only draw horizontal lines.
Now I'm just floundering around. I managed to draw a double vertical line
for Rect11 and just show a rectangle itself for Rect12.

I'd appreciate suggstions. Thanks.

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
Dim intWidth As Integer

On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)-(intLeft, intLineBottom)
Next

For intRects = 11 To 12
intWidth = Me("Rect" & intRects).Width
' If [Page] = 1 Then
' intWidth = intWidth + intRptHeadHeight 'no idea
' End If
Me.Line (intLeft, intTop)-(intLeft + intWidth, intLineBottom)
Next


Marshall Barton said:
Stephanie said:
Sorry for being cryptic. I can't use the line tool because lines drawn with
it don't export to RTF. So I need to use vba code to draw the lines.

Duane H. published code that I've used for vertical lines. I have
rectangles called Rect1 through Rect9. The code draws vertical lines from
the top, left-hand corner of the rectangles down from page header to footer.

But I can't seem to make horizontal lines with the code as well and would
appreciate coding help. Thanks:

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)- _
(intLeft, intLineBottom)
Next

On Error GoTo 0
Exit Sub

Report_Page_Error:
Select Case Err
Case 2462 'no page header
intPageHeadHeight = 0
Resume Next
End Select
MsgBox "Error " & Err.Number & " (" & _
Err.Description & ") in procedure " & _
"Report_Page of VBA Document Report_Report1"

End Sub


You need to specify the right side of the rectangle. Perhaps
just:

intWidth = Me("Rect" & intRects).Width
. . .
Me.Line (intLeft,intTop)-(intLeft+intWidth,intLineBottom)

But I won't garantee that Word can handle these lines any
better than regular line controls.
 
I should be more precise. Use:
Me.Line (intLeft,intTop)-(intLeft+intWidth,intLineBottom),,B
to draw rectangles.

Me.Line (intLeft,intTop)-(intLeft,intLineBottom)
to draw vertical lines at the intLeft position. This is
what you already have for rect 1 - 9

Me.Line (intLeft,intTop)-(intLeft+intWidth,intTop)
to draw intWidth long horizontal lines at the intTop
position. I'm still not sure about how long you want the
lines, but I think this is what you want for rect 11 - 12
--
Marsh
MVP [MS Access]

Thanks for the reply. Actually I have exported to RTF using Stephen Lebans'
utility that embeds the output of Snapshot Format inside an RTF file and it
does show my vertical lines that were written using vba, but not those made
with the line drawing tool.

I tried your suggestion for horizontal lines but was only able to draw
double vertical lines. Basically, I want Rect1...Rect9 to draw only vertical
lines. And I'd like, say, Rect11 and Rect12 to only draw horizontal lines.
Now I'm just floundering around. I managed to draw a double vertical line
for Rect11 and just show a rectangle itself for Rect12.

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
Dim intWidth As Integer

On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)-(intLeft, intLineBottom)
Next

For intRects = 11 To 12
intWidth = Me("Rect" & intRects).Width
' If [Page] = 1 Then
' intWidth = intWidth + intRptHeadHeight 'no idea
' End If
Me.Line (intLeft, intTop)-(intLeft + intWidth, intLineBottom)
Next

Stephanie said:
Sorry for being cryptic. I can't use the line tool because lines drawn with
it don't export to RTF. So I need to use vba code to draw the lines.

Duane H. published code that I've used for vertical lines. I have
rectangles called Rect1 through Rect9. The code draws vertical lines from
the top, left-hand corner of the rectangles down from page header to footer.

But I can't seem to make horizontal lines with the code as well and would
appreciate coding help. Thanks:

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)- _
(intLeft, intLineBottom)
Next

On Error GoTo 0
Exit Sub

Report_Page_Error:
Select Case Err
Case 2462 'no page header
intPageHeadHeight = 0
Resume Next
End Select
MsgBox "Error " & Err.Number & " (" & _
Err.Description & ") in procedure " & _
"Report_Page of VBA Document Report_Report1"

End Sub
Marshall Barton said:
You need to specify the right side of the rectangle. Perhaps
just:

intWidth = Me("Rect" & intRects).Width
. . .
Me.Line (intLeft,intTop)-(intLeft+intWidth,intLineBottom)
 
Marsh, thanks for the reply. I'm having limited success. Now, I'm trying to
draw a horizontal line for my subreport, no vertical lines involved, trying
to just figure out horizontal lines. My subreport contains only a details
section. It lists all of my "opportunities" in a single column (this is for
a calendar report). I was using a drawn line to separate the opportunities.
Now I'm trying to draw a horizontal line in code.
I was able to draw one horizontal line across the top of the opportunities
and then the same rectangle that was used to draw the line appeared as a
rectangle "separating" the opportunities, but didn't draw a line. What I
want are horizontal lines separating each opportunity:

Opportunity1
time
place
other stuff
--------------
Opportunity2
time
place
other stuff
-----------
Opportunity3...

Here, the width of the line is 1.5" wide. How can I get the rectangle tool
to repeat the horizontal line between each record? Thanks for the help.

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
Dim intWidth As Integer

On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins

For intRects = 1 To 1
intWidth = Me("Rect" & intRects).Width
'If [Page] = 1 Then
intWidth = intWidth + (1.5 * 1400)
'End If
Me.Line (intLeft, intTop)-(intLeft + intWidth, intTop)

Next

I should be more precise. Use:
Me.Line (intLeft,intTop)-(intLeft+intWidth,intLineBottom),,B
to draw rectangles.

Me.Line (intLeft,intTop)-(intLeft,intLineBottom)
to draw vertical lines at the intLeft position. This is
what you already have for rect 1 - 9

Me.Line (intLeft,intTop)-(intLeft+intWidth,intTop)
to draw intWidth long horizontal lines at the intTop
position. I'm still not sure about how long you want the
lines, but I think this is what you want for rect 11 - 12
--
Marsh
MVP [MS Access]

Thanks for the reply. Actually I have exported to RTF using Stephen Lebans'
utility that embeds the output of Snapshot Format inside an RTF file and it
does show my vertical lines that were written using vba, but not those made
with the line drawing tool.

I tried your suggestion for horizontal lines but was only able to draw
double vertical lines. Basically, I want Rect1...Rect9 to draw only vertical
lines. And I'd like, say, Rect11 and Rect12 to only draw horizontal lines.
Now I'm just floundering around. I managed to draw a double vertical line
for Rect11 and just show a rectangle itself for Rect12.

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
Dim intWidth As Integer

On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)-(intLeft, intLineBottom)
Next

For intRects = 11 To 12
intWidth = Me("Rect" & intRects).Width
' If [Page] = 1 Then
' intWidth = intWidth + intRptHeadHeight 'no idea
' End If
Me.Line (intLeft, intTop)-(intLeft + intWidth, intLineBottom)
Next

Stephanie wrote:
Sorry for being cryptic. I can't use the line tool because lines drawn with
it don't export to RTF. So I need to use vba code to draw the lines.

Duane H. published code that I've used for vertical lines. I have
rectangles called Rect1 through Rect9. The code draws vertical lines from
the top, left-hand corner of the rectangles down from page header to footer.

But I can't seem to make horizontal lines with the code as well and would
appreciate coding help. Thanks:

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)- _
(intLeft, intLineBottom)
Next

On Error GoTo 0
Exit Sub

Report_Page_Error:
Select Case Err
Case 2462 'no page header
intPageHeadHeight = 0
Resume Next
End Select
MsgBox "Error " & Err.Number & " (" & _
Err.Description & ") in procedure " & _
"Report_Page of VBA Document Report_Report1"

End Sub
Marshall Barton said:
You need to specify the right side of the rectangle. Perhaps
just:

intWidth = Me("Rect" & intRects).Width
. . .
Me.Line (intLeft,intTop)-(intLeft+intWidth,intLineBottom)
 
There are no "Page" events or sections on subreports. If you want to draw a
horizontal line at the bottom of the bottom control in a detail section of a
subreport, add code to the On Print event of the section. This code assumes
your bottom-most control name is "txtLastTB".

Private Sub Detail_Print(Cancel As Integer, _
PrintCount As Integer)
Dim intBottom As Integer
intBottom = Me.txtLastTB.Top + Me.txtLastTB.Height
Me.Line (0, intBottom)-Step(Me.Width, 0)
End Sub

--
Duane Hookom
MS Access MVP


Stephanie said:
Marsh, thanks for the reply. I'm having limited success. Now, I'm trying
to
draw a horizontal line for my subreport, no vertical lines involved,
trying
to just figure out horizontal lines. My subreport contains only a details
section. It lists all of my "opportunities" in a single column (this is
for
a calendar report). I was using a drawn line to separate the
opportunities.
Now I'm trying to draw a horizontal line in code.
I was able to draw one horizontal line across the top of the opportunities
and then the same rectangle that was used to draw the line appeared as a
rectangle "separating" the opportunities, but didn't draw a line. What I
want are horizontal lines separating each opportunity:

Opportunity1
time
place
other stuff
--------------
Opportunity2
time
place
other stuff
-----------
Opportunity3...

Here, the width of the line is 1.5" wide. How can I get the rectangle
tool
to repeat the horizontal line between each record? Thanks for the help.

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
Dim intWidth As Integer

On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins

For intRects = 1 To 1
intWidth = Me("Rect" & intRects).Width
'If [Page] = 1 Then
intWidth = intWidth + (1.5 * 1400)
'End If
Me.Line (intLeft, intTop)-(intLeft + intWidth, intTop)

Next

I should be more precise. Use:
Me.Line (intLeft,intTop)-(intLeft+intWidth,intLineBottom),,B
to draw rectangles.

Me.Line (intLeft,intTop)-(intLeft,intLineBottom)
to draw vertical lines at the intLeft position. This is
what you already have for rect 1 - 9

Me.Line (intLeft,intTop)-(intLeft+intWidth,intTop)
to draw intWidth long horizontal lines at the intTop
position. I'm still not sure about how long you want the
lines, but I think this is what you want for rect 11 - 12
--
Marsh
MVP [MS Access]

Thanks for the reply. Actually I have exported to RTF using Stephen
Lebans'
utility that embeds the output of Snapshot Format inside an RTF file and
it
does show my vertical lines that were written using vba, but not those
made
with the line drawing tool.

I tried your suggestion for horizontal lines but was only able to draw
double vertical lines. Basically, I want Rect1...Rect9 to draw only
vertical
lines. And I'd like, say, Rect11 and Rect12 to only draw horizontal
lines.
Now I'm just floundering around. I managed to draw a double vertical
line
for Rect11 and just show a rectangle itself for Rect12.

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
Dim intWidth As Integer

On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)-(intLeft, intLineBottom)
Next

For intRects = 11 To 12
intWidth = Me("Rect" & intRects).Width
' If [Page] = 1 Then
' intWidth = intWidth + intRptHeadHeight 'no idea
' End If
Me.Line (intLeft, intTop)-(intLeft + intWidth, intLineBottom)
Next


Stephanie wrote:
Sorry for being cryptic. I can't use the line tool because lines
drawn with
it don't export to RTF. So I need to use vba code to draw the lines.

Duane H. published code that I've used for vertical lines. I have
rectangles called Rect1 through Rect9. The code draws vertical lines
from
the top, left-hand corner of the rectangles down from page header to
footer.

But I can't seem to make horizontal lines with the code as well and
would
appreciate coding help. Thanks:

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)- _
(intLeft, intLineBottom)
Next

On Error GoTo 0
Exit Sub

Report_Page_Error:
Select Case Err
Case 2462 'no page header
intPageHeadHeight = 0
Resume Next
End Select
MsgBox "Error " & Err.Number & " (" & _
Err.Description & ") in procedure " & _
"Report_Page of VBA Document Report_Report1"

End Sub


:
You need to specify the right side of the rectangle. Perhaps
just:

intWidth = Me("Rect" & intRects).Width
. . .
Me.Line (intLeft,intTop)-(intLeft+intWidth,intLineBottom)
 
Stephanie, it looks like you are just using copy/paste on a
bunch of code without getting a grip on the principles. As
Duane said, all the code having to do with page numbers and
page size has nothing to do with either subreports or what
you want to do in the subreport. Get rid of it.

Another thing I see is that you never set intLeft, but since
its supposed to be 0, you do not really need it.

I'm pretty sure that after getting rid of all that useless
code, you will only need the one line that Duane posted.
--
Marsh
MVP [MS Access]

Marsh, thanks for the reply. I'm having limited success. Now, I'm trying to
draw a horizontal line for my subreport, no vertical lines involved, trying
to just figure out horizontal lines. My subreport contains only a details
section. It lists all of my "opportunities" in a single column (this is for
a calendar report). I was using a drawn line to separate the opportunities.
Now I'm trying to draw a horizontal line in code.
I was able to draw one horizontal line across the top of the opportunities
and then the same rectangle that was used to draw the line appeared as a
rectangle "separating" the opportunities, but didn't draw a line. What I
want are horizontal lines separating each opportunity:

Opportunity1
time
place
other stuff
--------------
Opportunity2
time
place
other stuff
-----------
Opportunity3...

Here, the width of the line is 1.5" wide. How can I get the rectangle tool
to repeat the horizontal line between each record? Thanks for the help.

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
Dim intWidth As Integer

On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins

For intRects = 1 To 1
intWidth = Me("Rect" & intRects).Width
'If [Page] = 1 Then
intWidth = intWidth + (1.5 * 1400)
'End If
Me.Line (intLeft, intTop)-(intLeft + intWidth, intTop)

Next

I should be more precise. Use:
Me.Line (intLeft,intTop)-(intLeft+intWidth,intLineBottom),,B
to draw rectangles.

Me.Line (intLeft,intTop)-(intLeft,intLineBottom)
to draw vertical lines at the intLeft position. This is
what you already have for rect 1 - 9

Me.Line (intLeft,intTop)-(intLeft+intWidth,intTop)
to draw intWidth long horizontal lines at the intTop
position. I'm still not sure about how long you want the
lines, but I think this is what you want for rect 11 - 12
--
Marsh
MVP [MS Access]

Thanks for the reply. Actually I have exported to RTF using Stephen Lebans'
utility that embeds the output of Snapshot Format inside an RTF file and it
does show my vertical lines that were written using vba, but not those made
with the line drawing tool.

I tried your suggestion for horizontal lines but was only able to draw
double vertical lines. Basically, I want Rect1...Rect9 to draw only vertical
lines. And I'd like, say, Rect11 and Rect12 to only draw horizontal lines.
Now I'm just floundering around. I managed to draw a double vertical line
for Rect11 and just show a rectangle itself for Rect12.

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
Dim intWidth As Integer

On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)-(intLeft, intLineBottom)
Next

For intRects = 11 To 12
intWidth = Me("Rect" & intRects).Width
' If [Page] = 1 Then
' intWidth = intWidth + intRptHeadHeight 'no idea
' End If
Me.Line (intLeft, intTop)-(intLeft + intWidth, intLineBottom)
Next


Stephanie wrote:
Sorry for being cryptic. I can't use the line tool because lines drawn with
it don't export to RTF. So I need to use vba code to draw the lines.

Duane H. published code that I've used for vertical lines. I have
rectangles called Rect1 through Rect9. The code draws vertical lines from
the top, left-hand corner of the rectangles down from page header to footer.

But I can't seem to make horizontal lines with the code as well and would
appreciate coding help. Thanks:

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)- _
(intLeft, intLineBottom)
Next

On Error GoTo 0
Exit Sub

Report_Page_Error:
Select Case Err
Case 2462 'no page header
intPageHeadHeight = 0
Resume Next
End Select
MsgBox "Error " & Err.Number & " (" & _
Err.Description & ") in procedure " & _
"Report_Page of VBA Document Report_Report1"

End Sub


:
You need to specify the right side of the rectangle. Perhaps
just:

intWidth = Me("Rect" & intRects).Width
. . .
Me.Line (intLeft,intTop)-(intLeft+intWidth,intLineBottom)
 
Duane,
Thanks for the lesson on page and details. Obviously, vba code in reports is
quite beyond me. While I try not to use code that I totally don't
understand, it seems the only way to have the required lines to export to
RTF. I'll have to work on my understanding of reports. Thanks again!

Duane Hookom said:
There are no "Page" events or sections on subreports. If you want to draw a
horizontal line at the bottom of the bottom control in a detail section of a
subreport, add code to the On Print event of the section. This code assumes
your bottom-most control name is "txtLastTB".

Private Sub Detail_Print(Cancel As Integer, _
PrintCount As Integer)
Dim intBottom As Integer
intBottom = Me.txtLastTB.Top + Me.txtLastTB.Height
Me.Line (0, intBottom)-Step(Me.Width, 0)
End Sub

--
Duane Hookom
MS Access MVP


Stephanie said:
Marsh, thanks for the reply. I'm having limited success. Now, I'm trying
to
draw a horizontal line for my subreport, no vertical lines involved,
trying
to just figure out horizontal lines. My subreport contains only a details
section. It lists all of my "opportunities" in a single column (this is
for
a calendar report). I was using a drawn line to separate the
opportunities.
Now I'm trying to draw a horizontal line in code.
I was able to draw one horizontal line across the top of the opportunities
and then the same rectangle that was used to draw the line appeared as a
rectangle "separating" the opportunities, but didn't draw a line. What I
want are horizontal lines separating each opportunity:

Opportunity1
time
place
other stuff
--------------
Opportunity2
time
place
other stuff
-----------
Opportunity3...

Here, the width of the line is 1.5" wide. How can I get the rectangle
tool
to repeat the horizontal line between each record? Thanks for the help.

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
Dim intWidth As Integer

On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins

For intRects = 1 To 1
intWidth = Me("Rect" & intRects).Width
'If [Page] = 1 Then
intWidth = intWidth + (1.5 * 1400)
'End If
Me.Line (intLeft, intTop)-(intLeft + intWidth, intTop)

Next

I should be more precise. Use:
Me.Line (intLeft,intTop)-(intLeft+intWidth,intLineBottom),,B
to draw rectangles.

Me.Line (intLeft,intTop)-(intLeft,intLineBottom)
to draw vertical lines at the intLeft position. This is
what you already have for rect 1 - 9

Me.Line (intLeft,intTop)-(intLeft+intWidth,intTop)
to draw intWidth long horizontal lines at the intTop
position. I'm still not sure about how long you want the
lines, but I think this is what you want for rect 11 - 12
--
Marsh
MVP [MS Access]


Stephanie wrote:
Thanks for the reply. Actually I have exported to RTF using Stephen
Lebans'
utility that embeds the output of Snapshot Format inside an RTF file and
it
does show my vertical lines that were written using vba, but not those
made
with the line drawing tool.

I tried your suggestion for horizontal lines but was only able to draw
double vertical lines. Basically, I want Rect1...Rect9 to draw only
vertical
lines. And I'd like, say, Rect11 and Rect12 to only draw horizontal
lines.
Now I'm just floundering around. I managed to draw a double vertical
line
for Rect11 and just show a rectangle itself for Rect12.

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
Dim intWidth As Integer

On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)-(intLeft, intLineBottom)
Next

For intRects = 11 To 12
intWidth = Me("Rect" & intRects).Width
' If [Page] = 1 Then
' intWidth = intWidth + intRptHeadHeight 'no idea
' End If
Me.Line (intLeft, intTop)-(intLeft + intWidth, intLineBottom)
Next


Stephanie wrote:
Sorry for being cryptic. I can't use the line tool because lines
drawn with
it don't export to RTF. So I need to use vba code to draw the lines.

Duane H. published code that I've used for vertical lines. I have
rectangles called Rect1 through Rect9. The code draws vertical lines
from
the top, left-hand corner of the rectangles down from page header to
footer.

But I can't seem to make horizontal lines with the code as well and
would
appreciate coding help. Thanks:

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)- _
(intLeft, intLineBottom)
Next

On Error GoTo 0
Exit Sub

Report_Page_Error:
Select Case Err
Case 2462 'no page header
intPageHeadHeight = 0
Resume Next
End Select
MsgBox "Error " & Err.Number & " (" & _
Err.Description & ") in procedure " & _
"Report_Page of VBA Document Report_Report1"

End Sub


:
You need to specify the right side of the rectangle. Perhaps
just:

intWidth = Me("Rect" & intRects).Width
. . .
Me.Line (intLeft,intTop)-(intLeft+intWidth,intLineBottom)
 
Thanks for your time.

Marshall Barton said:
Stephanie, it looks like you are just using copy/paste on a
bunch of code without getting a grip on the principles. As
Duane said, all the code having to do with page numbers and
page size has nothing to do with either subreports or what
you want to do in the subreport. Get rid of it.

Another thing I see is that you never set intLeft, but since
its supposed to be 0, you do not really need it.

I'm pretty sure that after getting rid of all that useless
code, you will only need the one line that Duane posted.
--
Marsh
MVP [MS Access]

Marsh, thanks for the reply. I'm having limited success. Now, I'm trying to
draw a horizontal line for my subreport, no vertical lines involved, trying
to just figure out horizontal lines. My subreport contains only a details
section. It lists all of my "opportunities" in a single column (this is for
a calendar report). I was using a drawn line to separate the opportunities.
Now I'm trying to draw a horizontal line in code.
I was able to draw one horizontal line across the top of the opportunities
and then the same rectangle that was used to draw the line appeared as a
rectangle "separating" the opportunities, but didn't draw a line. What I
want are horizontal lines separating each opportunity:

Opportunity1
time
place
other stuff
--------------
Opportunity2
time
place
other stuff
-----------
Opportunity3...

Here, the width of the line is 1.5" wide. How can I get the rectangle tool
to repeat the horizontal line between each record? Thanks for the help.

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
Dim intWidth As Integer

On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins

For intRects = 1 To 1
intWidth = Me("Rect" & intRects).Width
'If [Page] = 1 Then
intWidth = intWidth + (1.5 * 1400)
'End If
Me.Line (intLeft, intTop)-(intLeft + intWidth, intTop)

Next

I should be more precise. Use:
Me.Line (intLeft,intTop)-(intLeft+intWidth,intLineBottom),,B
to draw rectangles.

Me.Line (intLeft,intTop)-(intLeft,intLineBottom)
to draw vertical lines at the intLeft position. This is
what you already have for rect 1 - 9

Me.Line (intLeft,intTop)-(intLeft+intWidth,intTop)
to draw intWidth long horizontal lines at the intTop
position. I'm still not sure about how long you want the
lines, but I think this is what you want for rect 11 - 12
--
Marsh
MVP [MS Access]


Stephanie wrote:
Thanks for the reply. Actually I have exported to RTF using Stephen Lebans'
utility that embeds the output of Snapshot Format inside an RTF file and it
does show my vertical lines that were written using vba, but not those made
with the line drawing tool.

I tried your suggestion for horizontal lines but was only able to draw
double vertical lines. Basically, I want Rect1...Rect9 to draw only vertical
lines. And I'd like, say, Rect11 and Rect12 to only draw horizontal lines.
Now I'm just floundering around. I managed to draw a double vertical line
for Rect11 and just show a rectangle itself for Rect12.

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
Dim intWidth As Integer

On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)-(intLeft, intLineBottom)
Next

For intRects = 11 To 12
intWidth = Me("Rect" & intRects).Width
' If [Page] = 1 Then
' intWidth = intWidth + intRptHeadHeight 'no idea
' End If
Me.Line (intLeft, intTop)-(intLeft + intWidth, intLineBottom)
Next


Stephanie wrote:
Sorry for being cryptic. I can't use the line tool because lines drawn with
it don't export to RTF. So I need to use vba code to draw the lines.

Duane H. published code that I've used for vertical lines. I have
rectangles called Rect1 through Rect9. The code draws vertical lines from
the top, left-hand corner of the rectangles down from page header to footer.

But I can't seem to make horizontal lines with the code as well and would
appreciate coding help. Thanks:

Private Sub Report_Page()

Dim intRects As Integer
Dim intPageHeadHeight As Integer
Dim intPageFootHeight As Integer
Dim intRptHeadHeight As Integer
Dim intLineBottom As Integer
Dim intLeft As Integer
Dim intTop As Integer
On Error GoTo Report_Page_Error
intRptHeadHeight = Me.Section(1).Height
intPageHeadHeight = Me.Section(3).Height
intPageFootHeight = Me.Section(4).Height
'find the y point of the bottom of line
intLineBottom = (11 * 1440) - _
(intPageFootHeight) - _
1440 'replace 1440 with total top and bottom margins
For intRects = 1 To 9
intLeft = Me("Rect" & intRects).Left
intTop = Me("Rect" & intRects).Top
If [Page] = 1 Then
intTop = intTop + intRptHeadHeight
End If
Me.Line (intLeft, intTop)- _
(intLeft, intLineBottom)
Next

On Error GoTo 0
Exit Sub

Report_Page_Error:
Select Case Err
Case 2462 'no page header
intPageHeadHeight = 0
Resume Next
End Select
MsgBox "Error " & Err.Number & " (" & _
Err.Description & ") in procedure " & _
"Report_Page of VBA Document Report_Report1"

End Sub


:
You need to specify the right side of the rectangle. Perhaps
just:

intWidth = Me("Rect" & intRects).Width
. . .
Me.Line (intLeft,intTop)-(intLeft+intWidth,intLineBottom)
 
Back
Top