On Thu, 29 Nov 2007 10:07:05 +0100, BzyQ wrote:
hi
how do I, in vba code, open a report by DoCmd.OpenReport in acViewNormal
mode and force it to print only the last page of it instead of the all
pages ?
BzyQ
Open it in acPreview, not in acNormal.
You can determine the last page of the report by including an unbound
control in the report's Page Footer section:
=[Pages]
or
="Page " & [Page] & " of " & [Pages]
If you don't wish to actually show the above control, just make it not
visible.
Then code a Command button click event on your form:
DoCmd.OpenReport "ReportName", acViewPreview, , , acHidden
DoCmd.SelectObject acReport, ReportName, False
DoCmd.PrintOut acPages, Reports!ReportName.[Pages],
Reports!ReportName.[Pages]
Docmd.close acReport, "ReportName"
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail