In access 2013 you can use a ‘line’ object to draw horizontal or vertical lines.
Typically you would draw a horizontal line through the ‘detail’ section to create a margin line between two fields.
However when you configure a field so it can grow if it contains more than a single line of text, these margin lines break and do not draw a consistent line through the detail section.
The steps below show how to make the ‘line’ object draw a continuous vertical line when a detail row has expanded due to a field growing.
- With your Access database open, open the navigation pane (on the left hand of the window) and then click on the arrow at the top and select ‘All Access Objects’
- Then right-click on the report you need to change the field in and select ‘Design View’
- If you do not already have a line object, add one in by selecting the ‘DESIGN’ menu option, then under ‘Controls’ clicking on the line and placing it in your report
- Click on the line object in the report.
- In the right side of the window you should see the ‘Property Sheet’. If you do not have the property sheet displayed, click on the ‘Property Sheet’ button which can be found under the ‘Design’ ribbon menu in the top of the screen.
- Take note of the name of the line object, in this example it is line83
- Now click on the ‘View Code’ button, this can be found under the ‘Design’ ribbon menu in the top of the screen.
- In the window that opens, paste in the following code – making sure to replace line83 with the name of your line object from step 9.
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim CtlDetail As Control
Dim intLineMargin As Integer
intLineMargin = 0
For Each CtlDetail In Me.Section(acDetail).Controls
If CtlDetail.Name = "line83" Then
Me.Line ((.Left + .Width + intLineMargin), 0)-(.Left + .Width + _
Set CtlDetail = Nothing
- Close the code editor and run your report.
- The line will now grow as fields grow.
- Don’t forget to save the changes!