Re: Termination of a vertical line

From: Duane Hookom (duanehookom_at_NoSpamHotmail.com)
Date: 03/21/05


Date: Mon, 21 Mar 2005 09:12:07 -0600

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

-- 
Duane Hookom
MS Access MVP
--
"Bill Schnur" <BillSchnur@discussions.microsoft.com> wrote in message 
news:2D760E5C-477D-4D35-AAD9-DA4723326CA3@microsoft.com...
> 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.
>
> "Duane Hookom" wrote:
>
>> 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.
>>
>> -- 
>> Duane Hookom
>> MS Access MVP
>> --
>>
>> "Bill Schnur" <BillSchnur@discussions.microsoft.com> wrote in message
>> news:096988BF-6BF0-4677-B793-BCAF28CAC7C9@microsoft.com...
>> > The records do include data from memo fields which can grow. Some 
>> > records
>> > will take up one line others may take 4 or 5.
>> >
>> > "Duane Hookom" wrote:
>> >
>> >> 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?
>> >>
>> >> -- 
>> >> Duane Hookom
>> >> MS Access MVP
>> >> --
>> >>
>> >> "Bill Schnur" <BillSchnur@discussions.microsoft.com> wrote in message
>> >> news:129F218D-B76F-419A-AD4E-B2E28DE5290F@microsoft.com...
>> >> > 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.
>> >> >
>> >> > "Duane Hookom" wrote:
>> >> >
>> >> >> 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
>> >> >>
>> >> >> -- 
>> >> >> Duane Hookom
>> >> >> MS Access MVP
>> >> >> --
>> >> >>
>> >> >> "Bill Schnur" <BillSchnur@discussions.microsoft.com> wrote in 
>> >> >> message
>> >> >> news:AC5609D7-E83E-488D-9481-D9F2FB702B9D@microsoft.com...
>> >> >> >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.
>> >> >> >
>> >> >> > "Duane Hookom" wrote:
>> >> >> >
>> >> >> >> 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.
>> >> >> >>
>> >> >> >> -- 
>> >> >> >> Duane Hookom
>> >> >> >> MS Access MVP
>> >> >> >> --
>> >> >> >>
>> >> >> >> "Bill Schnur" <BillSchnur@discussions.microsoft.com> wrote in
>> >> >> >> message
>> >> >> >> news:A58FB56C-2F89-46ED-AFC6-F3442AACF355@microsoft.com...
>> >> >> >> > 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.
>> >> >> >> >
>> >> >> >> > "Duane Hookom" wrote:
>> >> >> >> >
>> >> >> >> >> You didn't tell us which section of the report...
>> >> >> >> >> I would try add the code to the On Page event of the report.
>> >> >> >> >>
>> >> >> >> >> -- 
>> >> >> >> >> Duane Hookom
>> >> >> >> >> MS Access MVP
>> >> >> >> >> --
>> >> >> >> >>
>> >> >> >> >> "Bill Schnur" <BillSchnur@discussions.microsoft.com> wrote in
>> >> >> >> >> message
>> >> >> >> >> news:A93ACEBA-8074-4470-9416-BC24992C32AE@microsoft.com...
>> >> >> >> >> >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?
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>> 


Relevant Pages

  • Re: Termination of a vertical line
    ... someplace near the top and draw to some place near the bottom. ... Name your rectangles something ... >>> I have a report header, a page header and a page footer. ... Dim intNumLines As Integer ...
    (microsoft.public.access.reports)
  • Re: Termination of a vertical line
    ... I have a report header, a page header and a page footer. ... I only want one horizontal line at the bottom of the detail section or the ... > Dim intNumLines As Integer ...
    (microsoft.public.access.reports)
  • Re: add text to bottom of richtextbox, simple method? Solved
    ... It allows you to print the contents of a RichTextBox with selectable left, right, top and bottom page margins, and it works fine whether the RTB text runs to just one page or to several pages. ... Dim LineWidth As Long ... LeftMarginWidth As Long, ...
    (microsoft.public.vb.general.discussion)
  • Re: RTF printing problem
    ... If you run the modified code in my previous post it should tell you the size of the printer's unprintable bottom margin. ... Here is some code which allows you to print the contents of your RichTextBox in a different way, allowing you to specify precise page margins. ... Private Sub Command1_Click ... Dim LeftOffset As Long, TopOffset As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: cut and paste specific record on same worksheet
    ... to the bottom of all data. ... i need to do a sub total for data that does not ... For i = numofRows To 1 Step -1 ... Dim x As Integer, i As Integer, numofRows As Integer ...
    (microsoft.public.excel.programming)