Termination of a vertical line

G

Guest

I am using the following code in the Print Event to draw a vertical line on
my report.

Me.Line (0.0417 * 1440, 0)-Step(0, 20 * 1440)

I would like to have it stop a a horizontal line at the top of the page
footer section, however it stops about an 1/8" or so short. on the last page
the line stops in the middle of the page.

What am I doing wrong?
 
D

Duane Hookom

You didn't tell us which section of the report...
I would try add the code to the On Page event of the report.
 
G

Guest

The vertical lines are in the detail section. The horizontal line is to
appear at the bottom of the page with the vertical lines terminating at the
horizontal line. Sorry if you got this twice. I was not sure if the first one
response went through. Our system crashed as I was sending it.
 
D

Duane Hookom

What happened when you moved the code to the On Page event rather than the
detail section. You would need to decrease the "20*1440" to something about
half or less.
 
R

Rick Brandt

Bill said:
The vertical lines are in the detail section. The horizontal line is
to appear at the bottom of the page with the vertical lines
terminating at the horizontal line. Sorry if you got this twice. I
was not sure if the first one response went through. Our system
crashed as I was sending it.

The line method cannot extend a line beyond the boundaries of the section that
"owns" the event. So, if you use the format event of the detail section then
your line will never go above or below the detail section. The only way to make
the line go anywhere on the page is to use the Page event.
 
G

Guest

I have lines that go from the top limits of the page to the bottom through
the header and footer sections. Is there an easy way to get a horizontal line
to appear at the bottom of the detail section? How do I know where the bottom
of the detail section will be on each page? I am relatively new to VBA code.
I told someone I could duplicate a State of Illinois form and now I am
finding it is not as easy as I thought. Basically I just want the vertical
lines to extend the entire length of the detail section on each page with a
horizontal line at the bottom. Any help will be greatly appreciated.
 
D

Duane Hookom

Did you get the vertical line to work and terminate correctly?

Is your detail section height fixed?

Do you have more than one page?

Do you have report header or footer sections?

Do you have any grouping sections?

Here is some code that prints up to 30 horizontal lines across the page that
are space equal to the height of your detail section. If you want to change
the line spacing, just change the value of intDetailHeight to some other
number.

Private Sub Report_Page()
Dim intNumLines As Integer
Dim intLineNum As Integer
Dim intDetailHeight As Integer
Dim intPageHeadHeight As Integer
On Error GoTo Report_Page_Error

intNumLines = 30
intDetailHeight = Me.Section(acDetail).Height
intPageHeadHeight = Me.Section(3).Height
For intLineNum = 1 To intNumLines
Me.CurrentY = (intLineNum - 1) * _
intDetailHeight + intPageHeadHeight
Me.CurrentX = 0
Me.FontBold = True
Me.FontSize = 14
' remove the next line if you don't want _
to print line numbers
Me.Print intLineNum 'print the line number
Me.Line (0, intPageHeadHeight + _
intLineNum * intDetailHeight)- _
Step(Me.Width, 0)
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
 
G

Guest

The detail section grows depending on the number of records.
I will have more than one page (up to 10 or so)
I have a report header, a page header and a page footer.
I also have two groupings.

I only want one horizontal line at the bottom of the detail section or the
top of the page footer. Just picture a rectangle with 5 vertical lines to
define the columns and no lines in between each record.
 
D

Duane Hookom

The detail section doesn't grow "depending on the number of records". The
number of detail sections "rendered" depends on the number of records in
your report.

Again, will the detail section (for one record) ever grow/increase based on
the contents of a record? Is the detail section Can Grow property set to No?
 
G

Guest

The records do include data from memo fields which can grow. Some records
will take up one line others may take 4 or 5.
 
D

Duane Hookom

If you want vertical and horizontal lines to appear in the same place on
your page, on each page, you can use the Line method in the On Page event of
the report.

My previous posting had code that would do some of that. You can modify the
code to meet your needs. I think all you need are vertical lines that begin
someplace near the top and draw to some place near the bottom. Am I correct?
If I am correct, the best method that I am aware of is to place one or more
rectangles in the page header so that the top left corner of each rectangle
is the top left point of your vertical line. Name your rectangles something
like rct1, rct2, rct3,..

Come back with the names of your rectangles if I have guessed correctly.
Also tell us exactly how long the lines must be.
 
G

Guest

The rectangle idea sounds good. I would use Rect1 thru Rect6. I just want the
line to terminate at the top of the page footer section. The length of the
vertical line will vary between the first and second page because there is no
Report header on the second page. How do you get the bottom of the rectangles
to stop a the top of the page footer section? I wish I could draw you
something to describe this better. Sorry I have not been clear.
 
D

Duane Hookom

Here is some code that worked for me. I had top and bottom margins of .5"
each. You might need to replace "1440" as noted in the code below if your
margins are different.

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 6
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
 

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

Similar Threads


Top