Horizontal Line

C

ChoonBoy

Thank you in advance for your help.

I have a textbox in the detail section of my report. When the records are
many, it will flow over to the next page.

How do I use code to draw a horizontal line immediately below the last
record before it continue to the next page.

Regards
 
M

Marshall Barton

ChoonBoy said:
I have a textbox in the detail section of my report. When the records are
many, it will flow over to the next page.

How do I use code to draw a horizontal line immediately below the last
record before it continue to the next page.


Try adding a module level variable at the top of the
report's module:

Private lngPos As Long

Then use code in the detail section's Print event:

lngPos = Me.Top + Me.Height

And draw the line in the Page event:

Me.Line (0,lngPos)-Step(Me.Width,0)

You may want to set the detail section's KeepTogether
property to Yes??
 
C

ChoonBoy

Thanks for the reply,

I cannot get it working, no line appear below the last record. I am also not
able to find the Page event.

Regards
 
M

Marshall Barton

If you couldn't find the report's Page event procedure, that
line of code would be meaningless. So putting it anywhere
else could not possibly do anything useful.

Open the report in design view.

Use the View menu and select Properties.

In Report properties, select the Event tab.

Look down the list and click on the On Page property.

Select Event Procedure from the drop down list at the right
side of the property.

Then click on the builder button [...] to the right of the
drop list.

Paste the line of code:
Me.Line (0,lngPos)-Step(Me.Width,0)
into the event procedure.

Go back to the report's design view and click on the gray
Detail bar.

Go to the Detail properties window.

Select the Event tab.

Look down the list and click on the On Peint property.

Select Event Procedure from the drop down list at the right
side of the property.

Then click on the builder button [...] to the right of the
drop list.

Paste the line of code:
lngPos = Me.Top + Me.Height
into the event procedure.

Use the Drop down list at the top left side of the module
and select (General)

Add the line:
Private lngPos As Long
after the:
Option Compare Database
Option Explicit
lines. If those are not the first two lines in the module's
General section (blank lines don't matter), fix it so they
are.

Use the Debug menu and select Compile.

If there are no error messages, then switch the report to
Print Preview and see if you get a line in the right place.
 
C

ChoonBoy

Thank you so much for your response and the step by step guide.

I can now see the line below the last record for the page.

Only problem is, it does not appear immediately below the record but about
1/2 inch below and intersec with the information in the footer of the page.
Is there a way to avoid this.

Thanks again

Marshall Barton said:
If you couldn't find the report's Page event procedure, that
line of code would be meaningless. So putting it anywhere
else could not possibly do anything useful.

Open the report in design view.

Use the View menu and select Properties.

In Report properties, select the Event tab.

Look down the list and click on the On Page property.

Select Event Procedure from the drop down list at the right
side of the property.

Then click on the builder button [...] to the right of the
drop list.

Paste the line of code:
Me.Line (0,lngPos)-Step(Me.Width,0)
into the event procedure.

Go back to the report's design view and click on the gray
Detail bar.

Go to the Detail properties window.

Select the Event tab.

Look down the list and click on the On Peint property.

Select Event Procedure from the drop down list at the right
side of the property.

Then click on the builder button [...] to the right of the
drop list.

Paste the line of code:
lngPos = Me.Top + Me.Height
into the event procedure.

Use the Drop down list at the top left side of the module
and select (General)

Add the line:
Private lngPos As Long
after the:
Option Compare Database
Option Explicit
lines. If those are not the first two lines in the module's
General section (blank lines don't matter), fix it so they
are.

Use the Debug menu and select Compile.

If there are no error messages, then switch the report to
Print Preview and see if you get a line in the right place.
--
Marsh
MVP [MS Access]

I cannot get it working, no line appear below the last record. I am also not
able to find the Page event.
 
M

Marshall Barton

ChoonBoy said:
Thank you so much for your response and the step by step guide.

I can now see the line below the last record for the page.

Only problem is, it does not appear immediately below the record but about
1/2 inch below and intersec with the information in the footer of the page.
Is there a way to avoid this.


I forgot to account for the report's top margin, sorry.

If you are using A2003 or later, try changing the one line
of code to:

lngPos = Me.Top + Me.Height - Me.Printer.TopMargin

If you have an earlier version:

lngPos = Me.Top + Me.Height - {top margin in inches} * 1440
 
C

ChoonBoy

Thank you, this is exactly what I wanted.

Now I only need to know how to adjust the width of the line. Is this possible?

Regards
 
M

Marshall Barton

Just change the line's start and end points. I.e. change
the first 0 and/or Me.Width in
Me.Line (0,lngPos)-Step(Me.Width,0)
to whatever whatever start and/or end points you want. Note
that the coordinates are specified in twips (1440 twips per
inch).

If you want the line to start at the left side of
thistextbox and end at the right side of thattextbox, you
could use:
Me.Line
(Me.thistextbox.Left,lngPos)-Step(Me.thattextbox.Left+Me.thattextbox.Width,0)
 
M

Marshall Barton

ChoonBoy said:
Now I only need to know how to adjust the width of the line. Is this possible?


Whoops. That was supposed to be:

If you want the line to start at the left side of
thistextbox and end at the right side of thattextbox, you
could use:
Me.Line
(Me.thistextbox.Left,lngPos)-(Me.thattextbox.Left+Me.thattextbox.Width,lngPos)
 

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