Print Report Using a Messagebox

G

Guest

Hi,
I currently have a form with 2 buttons on it, 1 to print page one, one to
print page 2. I would like a messagebox to pop up saying Print Page 1?,
vbyesno and then Print Page 2, vbyesno.

The only trouble is I don't know what command to put to print each report if
Yes is clicked. Any ideas?

Thanks
 
S

Scott McDaniel

Hi,
I currently have a form with 2 buttons on it, 1 to print page one, one to
print page 2. I would like a messagebox to pop up saying Print Page 1?,
vbyesno and then Print Page 2, vbyesno.

The only trouble is I don't know what command to put to print each report if
Yes is clicked. Any ideas?

If you mean you only want to print Page1 of a report with more than one page, then you'll need to use DoCmd.PrintOut:

'/first open the report in Preview mode
DoCmd.OpenReport "YourReportName", acViewPreview
'/now print it
DoCmd.PrintOut acPages, 1, 1

This would print the first page; to print the second:

DoCmd.PrintOut acPages, 2, 2

To show your messagebox:

If Msgbox("Print Page 1?", vbYesNo + vbQuestion, "Print")=vbYes Then
DoCmd.OpenReport "YourReportName", acViewPreview
DoCmd.Printout acPages, 1, 1
End If

Same applies to the Print Page 2 button, with obvious changes.

If you have TWO reports that need to be printed (i.e. one report that is to be printed when the user presses the first
button, and a second separate report that prints when pressing the second button) then don't use the DoCmd.Printout,
instead just use DoCmd.OpenReport without the acViewpreview agrument.

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 

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