Box Around Detail Section

  • Thread starter Thread starter John Lane
  • Start date Start date
J

John Lane

I have a report with multiple rows (of course!) and I would like to put a box
around the entire detail section on each page. I know that I can put in
vertical lines on each row, and a line at the top, but I can't figure out how
to make sure the is a line at the bottom when very possibly the last page
won't fill all the way so (cheating and putting a line in the page footer).
Any ideas? Thanks.
 
You can try use the Line method of the report. First add a text box to the
Report Header section:
Name: txtCount
Control Source: =Count(*)
Visible: No
The add a text box to the Detail section:
Name: txtCountDetail
Control Source: =1
Running Sum: Over All
Visible: No
Add a text box to the Page footer:
Control Source: =Page & " of " & Pages

Then add this code which will draw all of the lines. You will need to change
the hard-coded value 14400 based on your needs.

Option Compare Database
Option Explicit

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Page = Pages Then
Me.Line (0, 0)-Step(0, Me.Height)
Me.Line (Me.Width, 0)-Step(0, Me.Height)
End If
If Me.txtCount = Me.txtCountDetail Then
Me.Line (0, Me.Height)-Step(Me.Width, 0)
End If
End Sub

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
If Page <> Pages Then
Me.Line (0, 0)-Step(Me.Width, 0)
End If
End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
Me.Line (0, Me.Height)-Step(Me.Width, 0)
End Sub

Private Sub Report_Page()
Dim intTop As Integer

Dim lngHeight As Long
If Page <> Pages Then
If Page > 1 Then
intTop = Me.Section(3).Height
lngHeight = 14400
Else
intTop = Me.Section(1).Height + Me.Section(3).Height
lngHeight = 14400 - Me.Section(4).Height
End If
Me.Line (0, intTop)-Step(0, lngHeight)
Me.Line (Me.Width, intTop)-Step(0, lngHeight)
End If
End Sub
 
You can try use the Line method of the report. First add a text box to the
Report Header section:
Name: txtCount
Control Source: =Count(*)
Visible: No
The add a text box to the Detail section:
Name: txtCountDetail
Control Source: =1
Running Sum: Over All
Visible: No
Add a text box to the Page footer:
Control Source: =Page & " of " & Pages

Then add this code which will draw all of the lines. You will need to change
the hard-coded value 14400 based on your needs.

Option Compare Database
Option Explicit

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Page = Pages Then
Me.Line (0, 0)-Step(0, Me.Height)
Me.Line (Me.Width, 0)-Step(0, Me.Height)
End If
If Me.txtCount = Me.txtCountDetail Then
Me.Line (0, Me.Height)-Step(Me.Width, 0)
End If
End Sub

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
If Page <> Pages Then
Me.Line (0, 0)-Step(Me.Width, 0)
End If
End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
Me.Line (0, Me.Height)-Step(Me.Width, 0)
End Sub

Private Sub Report_Page()
Dim intTop As Integer

Dim lngHeight As Long
If Page <> Pages Then
If Page > 1 Then
intTop = Me.Section(3).Height
lngHeight = 14400
Else
intTop = Me.Section(1).Height + Me.Section(3).Height
lngHeight = 14400 - Me.Section(4).Height
End If
Me.Line (0, intTop)-Step(0, lngHeight)
Me.Line (Me.Width, intTop)-Step(0, lngHeight)
End If
End Sub
 
Great! Thanks!

Duane Hookom said:
You can try use the Line method of the report. First add a text box to the
Report Header section:
Name: txtCount
Control Source: =Count(*)
Visible: No
The add a text box to the Detail section:
Name: txtCountDetail
Control Source: =1
Running Sum: Over All
Visible: No
Add a text box to the Page footer:
Control Source: =Page & " of " & Pages

Then add this code which will draw all of the lines. You will need to change
the hard-coded value 14400 based on your needs.

Option Compare Database
Option Explicit

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Page = Pages Then
Me.Line (0, 0)-Step(0, Me.Height)
Me.Line (Me.Width, 0)-Step(0, Me.Height)
End If
If Me.txtCount = Me.txtCountDetail Then
Me.Line (0, Me.Height)-Step(Me.Width, 0)
End If
End Sub

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
If Page <> Pages Then
Me.Line (0, 0)-Step(Me.Width, 0)
End If
End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
Me.Line (0, Me.Height)-Step(Me.Width, 0)
End Sub

Private Sub Report_Page()
Dim intTop As Integer

Dim lngHeight As Long
If Page <> Pages Then
If Page > 1 Then
intTop = Me.Section(3).Height
lngHeight = 14400
Else
intTop = Me.Section(1).Height + Me.Section(3).Height
lngHeight = 14400 - Me.Section(4).Height
End If
Me.Line (0, intTop)-Step(0, lngHeight)
Me.Line (Me.Width, intTop)-Step(0, lngHeight)
End If
End Sub
 
Great! Thanks!

Duane Hookom said:
You can try use the Line method of the report. First add a text box to the
Report Header section:
Name: txtCount
Control Source: =Count(*)
Visible: No
The add a text box to the Detail section:
Name: txtCountDetail
Control Source: =1
Running Sum: Over All
Visible: No
Add a text box to the Page footer:
Control Source: =Page & " of " & Pages

Then add this code which will draw all of the lines. You will need to change
the hard-coded value 14400 based on your needs.

Option Compare Database
Option Explicit

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Page = Pages Then
Me.Line (0, 0)-Step(0, Me.Height)
Me.Line (Me.Width, 0)-Step(0, Me.Height)
End If
If Me.txtCount = Me.txtCountDetail Then
Me.Line (0, Me.Height)-Step(Me.Width, 0)
End If
End Sub

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
If Page <> Pages Then
Me.Line (0, 0)-Step(Me.Width, 0)
End If
End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
Me.Line (0, Me.Height)-Step(Me.Width, 0)
End Sub

Private Sub Report_Page()
Dim intTop As Integer

Dim lngHeight As Long
If Page <> Pages Then
If Page > 1 Then
intTop = Me.Section(3).Height
lngHeight = 14400
Else
intTop = Me.Section(1).Height + Me.Section(3).Height
lngHeight = 14400 - Me.Section(4).Height
End If
Me.Line (0, intTop)-Step(0, lngHeight)
Me.Line (Me.Width, intTop)-Step(0, lngHeight)
End If
End Sub
 
Back
Top