Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Vertical lines in reports (Access 2000)

    I have a report with 8 columns. How could i divide them vertically with a line ?

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Vertical lines in reports (Access 2000)

    You can draw Vertical lines in the Detail section of the report, using the Line Tool from the toolbox.

    But ...are there controls that will Grow, and cause the detail section to also Grow. If that is the case, the lines will not grow when the section grows.
    You would need a more sophisticated solution that draws the lines with code in that case.
    Regards
    John



  3. #3
    5 Star Lounger
    Join Date
    Aug 2004
    Location
    Connecticut, USA
    Posts
    816
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Vertical lines in reports (Access 2000)

    Unless I'm missing something, you can use the line tool found in the Toolbox (same place you can add a Label, Text Box,etc).

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Vertical lines in reports (Access 2000)

    You can copy the following function into a standard module:

    Sub DrawLines(R As Report, ParamArray xPos())
    ' Number of twips in one inch.
    Const OneInch = 1440
    ' Maximum height of a section in inches.
    Const MaxHeight = 22
    ' Loop index
    Dim i As Integer
    ' Draw vertical line at xPos(i) inches from left margin. Covers entire section.
    For i = LBound(xPos) To UBound(xPos)
    R.Line (xPos(i) * OneInch, 0)-(xPos(i) * OneInch, MaxHeight * OneInch)
    Next i
    End Sub

    and use it like this in the On Print event of the Detail section of your report:

    Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    ' Draw vertical lines at 1", 2.5", 4", and 5.5" from left margin.
    DrawLines Me, 1, 2.5, 4, 5.5
    End Sub

    You can add more numbers, and make them correspond to the positions of the vertical lines to be drawn in your report.

    Note: you MUST use a decimal point in VBA, even if your system uses a comma as decimal separator.

  5. #5
    4 Star Lounger
    Join Date
    Jan 2003
    Location
    Central Florida, USA
    Posts
    505
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Vertical lines in reports (Access 2000)

    Hans,

    That is AWESOME! ! ! I have spent many many hours manually drawing and placing lines. I wish I had known of this. Very kewl.

    Is there a way to control the weight/Border width of the line?

    Ken

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Vertical lines in reports (Access 2000)

    You can change the line

    R.Line (xPos(i) * OneInch, 0)-(xPos(i) * OneInch, MaxHeight * OneInch)

    to

    R.Line (xPos(i) * OneInch, 0)-(xPos(i) * OneInch + 20, MaxHeight * OneInch), BF

    BF stands for Box, Filled. The + 20 makes the line (actually a filled rectangle) 20 twips = 1 point wide; you can increase the number 20 for an even thicker line - experiment to get the result that you want.

  7. #7
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Vertical lines in reports (Access 2000)

    Here is a version I use where I have controls that grow.
    <pre> Me.DrawWidth = 2
    Dim ctrl As Control, MaxHeight As Integer
    MaxHeight = 0
    For Each ctrl In Me
    If ctrl.Height > MaxHeight Then MaxHeight = ctrl.Height
    Next ctrl
    For Each ctrl In Me
    If ctrl.Tag = "BoxMe" Then
    Me.Line (ctrl.Left - 30, ctrl.Top - 30)-(ctrl.Left - 30, ctrl.Top + MaxHeight + 30), rgb(0, 0, 0)

    End If
    Next ctrl
    </pre>


    The first line determines the width of the lines.
    I may not want a line to the left of each textbox, so I use the Tag property to control which ones get a line. I use BoxMe, but anything could be used.
    The first loop determines the max height , and uses that as the Line height.
    Added later
    If I want a line at the right hand edge, I put in a dummy hidden text box at the right.
    Regards
    John



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •