Total Pages of Report

M

Michael Conroy

When a person submits a report to the printer I have a little message box
that asks if they are sure they want to print this. What I really want is for
the message box to say that the report is X number of pages long, are you
sure you want to print this. I just want to give the user a chance to stop a
huge report (between 300 and 900 pages) from going to the printer. Each time
they execute a report, a tabledef called OutPutDate is created and all the
reports use it as their recordsource, if that helps. Any help would be
appreciated.
 
J

John Spencer

Here is a code snippet that should get the number of pages if the report is
not open. If it is open in preview you don't need to open and close it.

DoCmd.OpenReport "ReportName",acViewPreview,,,AcHidden
lPages = Reports("ReportName").Pages
DoCmd.Close acReport, "ReportName"

Now, if it is 900 pages, the delay may not be acceptable. As an alternative
you could try to get the record count from the underlying query and base the
warning on the number of records involved.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
M

Michael Conroy

John,
Thanks, that code worked after I took a comma out of the first command line.
I am working in Access 97 so maybe that's why. Opening the report and asking
for the pages seems so simple I guess I was trying to over think the
solution. Thanks again.
 
J

John Spencer

The extra comma was my error. I typed the code snippet directly into the
newsreader.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 

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