Option Compare Database
Option Explicit
Dim lngPage As Long
' this code uses Lines set into the detail section
' that have their Visible property set to False.
' We redraw new lines in the same location that
' are slightly larger than the tallest TextBox
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim sngLineTop As Single
Dim sngLineLeft As Single
Dim sngLineWidth As Single
Dim sngLineHeight As Single
Dim ctl As Control
Dim lngH As Long
'if new page then draw a line at the top of the detail section
If lngPage <> Me.Page Then
Me.Line (0, 0)-Step(Me.Width, 0)
lngPage = Me.Page
End If
'get the height of the tallest TextBox
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If Me(ctl.Name).Height > lngH Then
lngH = Me(ctl.Name).Height
End If
End If
Next ctl
'draw a new line in the same spot as existing lines
For Each ctl In Me.Controls
If ctl.ControlType = acLine Then
sngLineTop = Me(ctl.Name).Top
'4320 twips equals 3 inches
sngLineLeft = Me(ctl.Name).Left
'20 twips equals approximately 1 point (1/72 inch)
sngLineWidth = Me(ctl.Name).Width
sngLineHeight = 0 + lngH + 10
Me.Line (sngLineLeft, sngLineTop)-Step(sngLineWidth, sngLineHeight)
End If
Next ctl
'draw a line at the bottom of the Detail Section
sngLineTop = lngH + 10
sngLineLeft = 0
sngLineWidth = Me.Width
sngLineHeight = 0
Me.Line (sngLineLeft, sngLineTop)-Step(sngLineWidth, sngLineHeight)
End Sub
goes in the code window behind the report. You have to place vertical lines on the report in the detail section where you want them, then set their visible property to false .. and then open the report, and you should have gridlines.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.