Variable lines on a report

G

Guy Scharf

I am trying to prepare a report that will include, on each page, a
variable number of lines for people to write on. At the top of the
page, I am printing some memo fields, which are of varying lengths but
short enough that there will always be blank space at the bottom of the
page. The detail section will each be on its own page. At the bottom
of the page, I want to add lines for people to write names and dates.
Think of it as a library card on 8.5"x11" paper with a description of
the item at the top and a place to record checking out of material
below.

I would like to have those lines fill the page, but not flow over into
an additional page. The amount of space available, and thus the number
of lines I want to have, will vary from page to page. I would expect
there always to be at least 10 lines and sometimes as many as 40.

How might I accomplish that? This is my first Access application, and
I have no idea how to approach this problem.

Thanks!

Guy
 
M

Marshall Barton

Guy said:
I am trying to prepare a report that will include, on each page, a
variable number of lines for people to write on. At the top of the
page, I am printing some memo fields, which are of varying lengths but
short enough that there will always be blank space at the bottom of the
page. The detail section will each be on its own page. At the bottom
of the page, I want to add lines for people to write names and dates.
Think of it as a library card on 8.5"x11" paper with a description of
the item at the top and a place to record checking out of material
below.

I would like to have those lines fill the page, but not flow over into
an additional page. The amount of space available, and thus the number
of lines I want to have, will vary from page to page. I would expect
there always to be at least 10 lines and sometimes as many as 40.


There is no built in way to do that so you will have to use
VBA code in the report's Page event procedure.

First, add a hidden unbound text box named txtHeight to the
detail section. Use a line of code in the detail section's
Print event procedure to set the text box's value to the
final height of the detail section.

Then, the code in the report's Page event can use the Line
method to draw the lines.

The related part of the report's module could then be:
-------------------------------------------------------------
Option Explicit

Const TPI As Long = 1440 'twips per inch
' change these to agree with the report settings
Const LineSpace As Long = 0.25 * TPI
Const PageHeight As Long = 11 * TPI
Const TopMargin As Long = 0.5 * TPI
Const BottomMargin As Long = 1 * TPI

Private Sub Detail_Print(Cancel As Integer, _
PrintCount As Integer)
Me.txtHeight = Me.Height
End Sub

Private Sub Report_Page()
Dim StartPos As Long
Dim EndPos As Long
Dim k As Long

StartPos = Me.Section(3).Height + Me.txtHeight
EndPos = PageHeight - TopMargin - BottomMargin _
- Me.Section(4).Height
For k = StartPos + LineSpace To EndPos Step LineSpace
Me.Line (0, k)-(Me.Width, k)
Next k
End Sub
 
G

Guy Scharf

Marsh,

Thank you so much for your help. It has got me started, but I am
having a problem with Me.Line. Here is my Page Event section:

Private Sub Report_Page()
Dim StartPos As Long
Dim EndPos As Long
Dim k As Long
Dim intHeaderHeight As Integer
Dim intFooterHeight As Integer

intHeaderHeight = Me.Section(3).Height
intFooterHeight = Me.Section(4).Height

StartPos = intHeaderHeight + Me.txtHeight
EndPos = PageHeight - TopMargin - BottomMargin - intFooterHeight -
LineSpace

Me.DrawWidth = 2

For k = StartPos To EndPos Step LineSpace
Me.Line (0, k)-(Me.Width, k)
Me.Line (0, k - LineSpace)-(0, k)
Me.Line (1, k - LineSpace)-(1, k)
Me.Line (2, k - LineSpace)-(2, k)
Next k
End Sub

I seem unable to set the starting x position for Me.Line. I've tried
drawing horizontal lines starting at 1, or vertical lines positioned at
X other than zero, but the lines always end up at the left edge. What
might I be doing wrong?

Thanks!

Guy
 
G

Guy Scharf

Never mind, I figured out that I had to multiply all my inches
dimensions by TPI.

Thanks for your help. I think I have this working well!

Guy
 

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