Print only one page

J

Jone

Hi everybody!
What code to I have to write when I want to print a page from my report
without the print dialog box to come up?

Let’s say I only want page 2 to 2 should print I want to make a button and
when that button is pressed ONLY page 2 of 2 will print
 
J

John Spencer

Perhaps what you want is the following.

Public Function fPrintCurrentPage()
'Assign this function to a button on a menubar or button bar to
'print the currently displayed page of a report open in preview

Dim intCurrentPageNo As Integer
Dim CurrentRptName As Report

On Error GoTo ERROR_PrtCurrentPg

Set CurrentRptName = Screen.ActiveReport
intCurrentPageNo = CurrentRptName.Page
DoCmd.PrintOut acPages, intCurrentPageNo, intCurrentPageNo

EXIT_PrtCurrentPg:
On Error Resume Next
Exit Function

ERROR_PrtCurrentPg:
Select Case Err.Number
Case 2476
'No report selected

Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, , _
"Module.modMenuFunctions.fPrintCurrentPage"
Resume EXIT_PrtCurrentPg
End Select
End Function


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