Report Border - How do I draw one in VBA?

D

Dennis

I am trying to put a border around my reports; here is the code that I found
in the news group help file.

Me.DrawWidth = 2
Me.Line (0, 0)-(Me.ScaleWidth, Me.ScaleHeight), B


I am using the below code module to preview my reports, I have over 20
reports so I just call the PreviewThisReport function, from within the form
that I need to preview the report from. Where would I put the above code or
would I have to change the code? Is there an easier way to do it? VBA is some
what new to me. I guess I don’t understand the “Me.†Keyword. Help would be
appreciated.


'function Previews report
Function PreviewThisReport(strReportName As String)

On Error GoTo IsLoaded_Err

'find preview report

DoCmd.OpenReport strReportName, acViewPreview
DoCmd.RunCommand acCmdFitToWindow
DoCmd.RunCommand acCmdZoom75

Exit Function

IsLoaded_Err:
Resume Next

End Function
 
W

Wayne Morgan

The code would go in the Page event of the report. The help file has the
same example as the one you posted. One thing to be aware of, this will
print the border at the margins (File|Page Setup...) you have set for the
report (not at the edge of the paper). If these margins are outside your
printer's printable area, then the border won't print.

"Me" refers to the module the code is running in. You could say
"Reports!MyReport", but Me is shorter. If you were referring to the report
form somewhere else though, such as from a form, you would have to use the
longer version. You can use Me in any module to refer to the current module.
If that module is a form or report module, you can also use Me as if it
refers to the form or report that the code is running in.
 
D

Dennis

I put the code in the Page event of the report and it drew a diagonal line
from the left upper corner to the lower right corner of the report. My print
margins are set at .5â€. Any idea’s what I’m doing wrong?
 
D

Duane Hookom

Sorry I missed this but you need to add another comma
Me.Line (0, 0)-(Me.ScaleWidth, Me.ScaleHeight), , B
 
D

Dennis

That did it Duane, now the only problem I,m having is that it's clipping off
the bottom part of the border, do I have the report page height set to high?

Thanks for the Help!
 
M

Marshall Barton

Dennis said:
That did it Duane, now the only problem I,m having is that it's clipping off
the bottom part of the border, do I have the report page height set to high?
Just subtract a small amount from the height in the line
method:

Me.Line (0, 0)-(Me.ScaleWidth, Me.ScaleHeight - 30), , B
 

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