how to open report and print out page 2 to page3

  • Thread starter Thread starter help
  • Start date Start date
H

help

how to open report and print out page 2 to page3

"docmd.openreport " can open report and print out all pages ,how can I only
print out page 2 to page 4?
 
I would think that you would be better off to use the appropriate
WhereCondition parameter, so that you only open the report with the records
that you wish to print. That way, if you happen to have a huge report, you
would not be having to wait for all of the report to format correctly in
preview mode. For example:

Private Sub cmdPreviewChangeBoardReview_Click()
On Error GoTo ProcError

DoCmd.OpenReport _
"rptChangeBoard", _
View:=acViewPreview, _
WhereCondition:="[Status_txt] = 'Review' " _
& "And [blnInactiveRecord] <> -1"

ExitProc:
Exit Sub
ProcError:
Select Case Err.Number
Case 2501 'Report cancled.
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, , _
"Error in cmdPreviewChangeBoardReview_Click event
procedure..."
End Select
Resume ExitProc
End Sub


Trapping for error 2501 is a good idea, when combined with using the No_Data
event procedure in a report to cancle opening a report, if there is no data
that meets the specified criteria.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
Tom's given you the preferred method. However, be aware that there is a
PrintOut method that will let you print only specific pages of the active
report.

After your DoCmd.OpenReport statement (opening the report in Preview mode,
of course), put:

DoCmd.PrintOut acPages, 2, 4

Note that relying on the active report, though, can lead to problems. If
your user has clicked on something else in the application while the report
is opening, it's possible that the desired report will not be active.
 

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

Back
Top