Add/Draw blank lines to access report

K

kyle775

I have a report that sometimes has 1 record in the detail section and
sometimes it may have 10+ records. When there is not enough records
to fill the space on the page, i would like to show blank lines in
that area so after the report is printed people can add to the
section.
So for example i have this,
[Detail]
Record 1
Record 2




[footer]

and i would prefer,
[Detail]
Record 1
Record 2
________
________
________
________
[footer]

The blank lines need to grow or shrink depending on how many detail
records there are.
I have seen many posts where vertical lines are required or boxes and
grids.
my knowledge of VBA isnt extensive to the point that i could modify
those bits of code to get my result. Can anyone give me some help?
 
M

Marshall Barton

kyle775 said:
I have a report that sometimes has 1 record in the detail section and
sometimes it may have 10+ records. When there is not enough records
to fill the space on the page, i would like to show blank lines in
that area so after the report is printed people can add to the
section.
So for example i have this,
[Detail]
Record 1
Record 2




[footer]

and i would prefer,
[Detail]
Record 1
Record 2
________
________
________
________
[footer]

The blank lines need to grow or shrink depending on how many detail
records there are.
I have seen many posts where vertical lines are required or boxes and
grids.
my knowledge of VBA isnt extensive to the point that i could modify
those bits of code to get my result. Can anyone give me some help?


You did not say which footer so I will assume it's the page
footer. If it's some other footer, this will not work.

First, add a module level (above the first procedure)
variable to the report's code module:

Private LinePos As Long

Then add this line to the Detail section's Format event
procedure:

LinePos = Me.Top + 2 * Me.Section(0).Height

Now, use the report's Page event procedure to draw the
lines:

Sub Report_Page()
For LinePos = LinePos To 10 * 1440 _
Step Me.Section(0).Height
Me.Line (0, y) - (Me.Width, y)
Next LinePos
End Sub

Change the 10 to the position on the paper where you want
the last line to be drawn.
 
K

kyle775

kyle775wrote:
I have a report that sometimes has 1 record in the detail section and
sometimes it may have 10+ records. When there is not enough records
to fill the space on the page, i would like to show blank lines in
that area so after the report is printed people can add to the
section.
So for example i have this,
[Detail]
Record 1
Record 2

and i would prefer,
[Detail]
Record 1
Record 2
________
________
________
________
[footer]
The blank lines need to grow or shrink depending on how many detail
records there are.
I have seen many posts where vertical lines are required or boxes and
grids.
my knowledge of VBA isnt extensive to the point that i could modify
those bits of code to get my result. Can anyone give me some help?

You did not say which footer so I will assume it's the page
footer. If it's some other footer, this will not work.

First, add a module level (above the first procedure)
variable to the report's code module:

Private LinePos As Long

Then add this line to the Detail section's Format event
procedure:

LinePos = Me.Top + 2 * Me.Section(0).Height

Now, use the report's Page event procedure to draw the
lines:

Sub Report_Page()
For LinePos = LinePos To 10 * 1440 _
Step Me.Section(0).Height
Me.Line (0, y) - (Me.Width, y)
Next LinePos
End Sub

Change the 10 to the position on the paper where you want
the last line to be drawn.

Thanks for the reply Marshall

Here is what my code looks like
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
LinePos = Me.Top + 2 * Me.Section(0).Height
End Sub

Private Sub Report_Page()
For LinePos = LinePos To 10 * 1440 _
Step Me.Section(0).Height
Me.Line (0, y)-(Me.Width, y)
Next LinePos
End Sub

with the following in "Module 1"
Private LinePos As Long

when i run the report i see a line a the top of the report header and
thats it....
im not quite sure what was meant by
"First, add a module level (above the first procedure)
variable to the report's code module: "
so i added that code into Module 1
sorry for my ignorance, VBA and access are not my first language :)
 
M

Marshall Barton

kyle775 said:
kyle775wrote:
I have a report that sometimes has 1 record in the detail section and
sometimes it may have 10+ records. When there is not enough records
to fill the space on the page, i would like to show blank lines in
that area so after the report is printed people can add to the
section.
So for example i have this,
[Detail]
Record 1
Record 2

and i would prefer,
[Detail]
Record 1
Record 2
________
________
________
________
[footer]
The blank lines need to grow or shrink depending on how many detail
records there are.
I have seen many posts where vertical lines are required or boxes and
grids.
my knowledge of VBA isnt extensive to the point that i could modify
those bits of code to get my result. Can anyone give me some help?

You did not say which footer so I will assume it's the page
footer. If it's some other footer, this will not work.

First, add a module level (above the first procedure)
variable to the report's code module:

Private LinePos As Long

Then add this line to the Detail section's Format event
procedure:

LinePos = Me.Top + 2 * Me.Section(0).Height

Now, use the report's Page event procedure to draw the
lines:

Sub Report_Page()
For LinePos = LinePos To 10 * 1440 _
Step Me.Section(0).Height
Me.Line (0, y) - (Me.Width, y)
Next LinePos
End Sub

Change the 10 to the position on the paper where you want
the last line to be drawn.

Here is what my code looks like
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
LinePos = Me.Top + 2 * Me.Section(0).Height
End Sub

Private Sub Report_Page()
For LinePos = LinePos To 10 * 1440 _
Step Me.Section(0).Height
Me.Line (0, y)-(Me.Width, y)
Next LinePos
End Sub

with the following in "Module 1"
Private LinePos As Long

when i run the report i see a line a the top of the report header and
thats it....
im not quite sure what was meant by
"First, add a module level (above the first procedure)
variable to the report's code module: "
so i added that code into Module 1
sorry for my ignorance, VBA and access are not my first language :)


Well, we both made a hash of that :-(

I seem to have changed variable names midstream and you put
the module level variable in the wrong module. (The
variable declaration must be in the **report** module.)

The code should be:

Private LinePos As Long

Private Sub Detail_Format(Cancel As Integer, FormatCount As
Integer)
LinePos = Me.Top + 2 * Me.Section(0).Height
End Sub

Private Sub Report_Page()
For LinePos = LinePos To 10 * 1440 _
Step Me.Section(0).Height
Me.Line (0, LinePos)-(Me.Width, LinePos)
Next LinePos
End Sub
 
K

kyle775

kyle775 said:
kyle775wrote:
I have a report that sometimes has 1 record in the detail section and
sometimes it may have 10+ records. When there is not enough records
to fill the space on the page, i would like to show blank lines in
that area so after the report is printed people can add to the
section.
So for example i have this,
[Detail]
Record 1
Record 2
[footer]
and i would prefer,
[Detail]
Record 1
Record 2
________
________
________
________
[footer]
The blank lines need to grow or shrink depending on how many detail
records there are.
I have seen many posts where vertical lines are required or boxes and
grids.
my knowledge of VBA isnt extensive to the point that i could modify
those bits of code to get my result. Can anyone give me some help?
You did not say which footer so I will assume it's the page
footer. If it's some other footer, this will not work.
First, add a module level (above the first procedure)
variable to the report's code module:
Private LinePos As Long
Then add this line to the Detail section's Format event
procedure:
LinePos = Me.Top + 2 * Me.Section(0).Height
Now, use the report's Page event procedure to draw the
lines:
Sub Report_Page()
For LinePos = LinePos To 10 * 1440 _
Step Me.Section(0).Height
Me.Line (0, y) - (Me.Width, y)
Next LinePos
End Sub
Change the 10 to the position on the paper where you want
the last line to be drawn.
Here is what my code looks like
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
LinePos = Me.Top + 2 * Me.Section(0).Height
End Sub
Private Sub Report_Page()
For LinePos = LinePos To 10 * 1440 _
Step Me.Section(0).Height
Me.Line (0, y)-(Me.Width, y)
Next LinePos
End Sub
with the following in "Module 1"
Private LinePos As Long
when i run the report i see a line a the top of the report header and
thats it....
im not quite sure what was meant by
"First, add a module level (above the first procedure)
variable to the report's code module: "
so i added that code into Module 1
sorry for my ignorance, VBA and access are not my first language :)

Well, we both made a hash of that :-(

I seem to have changed variable names midstream and you put
the module level variable in the wrong module. (The
variable declaration must be in the **report** module.)

The code should be:

Private LinePos As Long

Private Sub Detail_Format(Cancel As Integer, FormatCount As
Integer)
LinePos = Me.Top + 2 * Me.Section(0).Height
End Sub

Private Sub Report_Page()
For LinePos = LinePos To 10 * 1440 _
Step Me.Section(0).Height
Me.Line (0, LinePos)-(Me.Width, LinePos)
Next LinePos
End Sub

Thanks for your help! that works just as described.
very helpful!!!!!!!!!!!
 

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

Similar Threads


Top