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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print only first page and hidden

Status
Not open for further replies.

oxicottin

Programmer
Jun 20, 2008
353
US
Hello, I need to only print the first page of my report using vba and I need to not open the report so it needs to be hidden. I also would like to get a dialog but I cant figure it out... I can get it to print the one page using the code below but it briefly opens a preview of the report so I tried achidden and that just shows it in design view briefly then prints.
To get a dialg I can use DoCmd.RunCommand acCmdPrint and the dialog comes up but it prints the current visable page/form thats has focus. Here is what code I have as of now.

Code:
DoCmd.OpenReport "rpt_PrintRejectSlip", acViewPreview
DoCmd.PrintOut acPages, 1, 1
DoCmd.Close acReport, "rpt_PrintRejectSlip"

I can get it to print using...

Code:
DoCmd.OpenReport "rpt_PrintRejectSlip", acViewNormal

but I need it to only print one sheet and would like it to print with a dialog. The reason I dont want to see the preview is because it a bunch of bar cods and the preview is a blank page. I dont really care to much about the dialog but the one page is a must.

Ideas?


Thanks,
SoggyCashew.....
 
I wonder if you could use some code in the On Page event to close the report. I haven't tried this so you might need to play with it some.

Code:
Private Sub Report_Page()
    If Me.Page > 1 Then
        DoCmd.Close acReport, Me.Name
    End If
End Sub

Duane
Hook'D on Access
MS Access MVP
 
I tried it with the DoCmd.OpenReport "rpt_PrintRejectSlip", acViewNormal and it only worked if the report was a 1 page report. If it had more than one page it woundnt print anything.

Thanks,
SoggyCashew.....
 
The othe possible solution would be to set Cancel=True for every report section if the Page >1. You might need to add a page count control in a page section.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top