Box Around Detail Section

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.
 
D

Duane Hookom

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
 
D

Duane Hookom

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
 
J

John Lane

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
 
J

John Lane

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top