Search code examples
ms-accessreport

How to make all gridlines/borders consistent in Microsoft Access Report


I have this really frustrating problem that may or may not be fixable due to an access technicality, but I'm going to ask anyway.

On a report, I have multiple subreports that display a list of documents; and the information within those subreports are outlined by a grid, so that it looks like the documents are in a table.

My problem is, if I have the border of these objects too close, then sometimes the gridline/border outline is thicker in some areas and not in others. Why is this? It's making the report look really inconsistent and unpresentable.

The only way to combat this, is to leave a space between the object and the border section of the form. But then this means the documents are split and look like they are in their own tables, rather than one big table if this makes sense?

I can't seem to find any solutions to this at all. I'd be very grateful if you know how to fix this or can provide an alternative solution!

Please see the attached images:

UPDATE: I'd just like to add, that when I view the report in 'Report View'; it is presented correctly. This inconsistency only appears when I view it in 'Print view' or if I export it.

This shows what the report looks like if I leave a gap between the objects and the form border. Creating a table that's split between each document, but the lines are consistent in width/colour/boldness

This image shows that when I leave no gaps, the table looks connected and complete. However, some of the lines are thicker/bolder than others.

I am unable to overlap the documents because it is only one object that represents all of the documents from a table


Solution

  • Unfortunately, I was unable to find a simple answer as to why access creates these inconsistencies. However, I did find a workaround which solves the issue.

    Used this as a reference: https://msdn.microsoft.com/en-us/library/office/aa221362(v=office.11).aspx

    • Add a horizontal line underneath the objects on the report. This will separate the document rows

    • To get the vertical lines, I had to insert them via VBA code. This is because I was unable to get vertical lines to expand when the objects grow

       Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
       Dim ctrl As Control
       Dim intLineMargin As Integer
      
       ' This is the spacing between the right edge of the
       ' control and the Vertical Seperation Line
       intLineMargin = 0
      

    Loop through each control in the detail section of the subreport by selecting their Tags. The first object (Document) has an extra step, because you need vertical lines on both the left and right side.

    First if statement creates the line on the left and right side for all controls with the tag "DocumentName" (In this case, only the first object)

        For Each ctrl In Me.Section(acDetail).Controls
            With ctrl
    
                If ctrl.Tag = "DocumentName" Then
    
                    Me.Line (0, 0)-(0, 0 + .Height + 150)
        
                    Me.Line ((.Left + .Width), 0)-(.Left + .Width + intLineMargin, .Height + 150)
                End If
    

    The rest of the objects have the tag "DocumentDetails", and only need vertical lines on the RIGHT side of them. The if statement creates these vertical lines:

            If ctrl.Tag = "DocumentDetails" Then
            Me.Line ((.Left + .Width), 0)-(.Left + .Width + intLineMargin, .Height + 150)
            End If
    
        End With
    Next
    
    Set ctrl = Nothing
    
    
    End Sub
    

    Result: All lines are now consistent

    Consistent table lines