Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printing last two pages

Status
Not open for further replies.

SAPLearner

Programmer
Aug 9, 2003
3
US
Is there a way in access or vba that I can request to print the last two pages of a document no matter what the size of the document is.

I want to request last two pages of document one, last two pages of document two, first page of document three. etc...

Thanks,
Eva
 
use the following (take a look at the DoCmd.PrintOut command for more options):

DoCmd.PrintOut acPages, from, to

but you will first have to open the report, find the number of pages, and then use this to calculate what to print.

****************************
Computers are possibly the most un-intelligent things ever invented, yet we let them control the world. Possibly a reflection of our own stupidity.

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Thank you but it doesn't quite answer my question.

I want to be able to print automatically the last two pages of this document without knowing how many pages are in this document. The number of the pages changes daily.

Thanks,
Eva
 
Actually, it does answer your question...

If you do a search here in the forums, you will find code that will determine the number of pages in your report. Basically is opens the report hidden and cycles through the report...once the report is open, you can access the Report.PageCount property or some such.

Once this code has run, you use the PrintOut command...as the PrintOut command prints the active object...which is your hidden report. Since you now know the number fo pages, you merely use:

DoCmd.PrintOut acPages, (Report.PageCount - 1), Report.PageCount

substituting Report.PageCount with the appropriate name of the property if that is not correct.

****************************
Computers are possibly the most un-intelligent things ever invented, yet we let them control the world. Possibly a reflection of our own stupidity.

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top