INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Add Access Report Group Borders

Add Access Report Group Borders

(OP)
I have an Access Report with one grouping column (City). Within each City group, there may be anywhere from 1 to 5 companies. I was wondering if there is a way to put a border around each city section but not have borders between each company record.

RE: Add Access Report Group Borders

The answer might depend on whether or not a company section (maybe detail) is allowed to grow or not. If sections are not allowed to grow, you could combine horizontal lines in the City group header and footer section with vertical lines in the company section.

If any of these sections can grow then you may need to use code in the On Print event of the sections that uses the Line method to draw the lines.

Duane
Hook'D on Access
MS Access MVP

RE: Add Access Report Group Borders

(OP)
Thanks. Right now, I am putting a horizontal line in the City header and footer and vertical lines on the left and right of the detail section. This simulates a border around every city group, but if you zoom in when previewing the report, you can tell the borders are pieced together. I believe doing it this way eliminates problems if the company section were to grow in number of records. I'm just looking for a more robust way of insert borders.

RE: Add Access Report Group Borders

The most accurate method is to use the line method as I suggested. Plus it will handle sections that can grow. The following sample code assumes you have a horizontal line [ReferenceLine] in the Group Header section near the top. The width and position of the line is used as "markers" for the top of the box. Make the line invisible.

CODE --> vba

Option Compare Database
Option Explicit

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    ' Draw       |                                      |
    '            |                                      |
    '
    ' ReferenceLine is an invisible line in the Group Header section to pull measurements from
    
    Dim lngTop As Long, lngLeft As Long, lngRight As Long, lngWidth As Long, lngHeight As Long
    lngTop = Me.ReferenceLine.Top
    lngLeft = Me.ReferenceLine.Left
    lngWidth = Me.ReferenceLine.Width
    lngRight = lngLeft + lngWidth
    lngHeight = Me.Height
    Me.Line (lngLeft, 0)-Step(0, lngHeight)
    Me.Line (lngRight, 0)-Step(0, lngHeight)
    
End Sub

Private Sub GroupFooter1_Print(Cancel As Integer, PrintCount As Integer)
    
    '            |                                      |
    ' draw lines |______________________________________|
    '
    ' ReferenceLine is an invisible line in the Group Header section to pull measurements from
    
    Dim lngTop As Long, lngLeft As Long, lngRight As Long, lngWidth As Long, lngHeight As Long, lngGapBetween
    lngTop = 0
    lngGapBetween = 100   'spacing
    lngLeft = Me.ReferenceLine.Left
    lngWidth = Me.ReferenceLine.Width
    lngRight = lngLeft + lngWidth
    lngHeight = Me.Height - lngGapBetween
    Me.Line (lngLeft, lngHeight)-Step(lngWidth, 0)
    Me.Line (lngLeft, 0)-Step(0, lngHeight)
    Me.Line (lngRight, 0)-Step(0, lngHeight)
    
End Sub

Private Sub GroupHeader0_Print(Cancel As Integer, PrintCount As Integer)
    ' draw lines  ______________________________________
    '            |                                      |
    '
    ' ReferenceLine is an invisible line in the Group Header section to pull measurements from
    
    Dim lngTop As Long, lngLeft As Long, lngRight As Long, lngWidth As Long, lngHeight As Long
    lngTop = Me.ReferenceLine.Top
    lngLeft = Me.ReferenceLine.Left
    lngWidth = Me.ReferenceLine.Width
    lngRight = lngLeft + lngWidth
    lngHeight = Me.Height
    Me.Line (lngLeft, lngTop)-Step(lngWidth, 0)
    Me.Line (lngLeft, lngTop)-Step(0, Me.Height)
    Me.Line (lngRight, lngTop)-Step(0, Me.Height)
End Sub 

Duane
Hook'D on Access
MS Access MVP

RE: Add Access Report Group Borders

(OP)
I'm confused about what you mean by sections that could grow. The columns in the records in my detail section should always be the same height and width. Thanks for the code though. I will try this out soon.

RE: Add Access Report Group Borders

Every text box and section has a "Can Grow" property. If these are set to Yes, you can create gaps in lines if you are drawing using line controls.

Duane
Hook'D on Access
MS Access MVP

RE: Add Access Report Group Borders

(OP)
Gotcha. My text boxes are set to not grow, so I should be ok.

RE: Add Access Report Group Borders

You stated:

Quote (dmhgt3)

but if you zoom in when previewing the report, you can tell the borders are pieced together
Using the Line method, the more you zoom in, the more impressed you are with the lines winky smile

Duane
Hook'D on Access
MS Access MVP

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close