Printing reports through VBA

B

Brian

A while ago, I was using the following 4 lines of code to print reports from
an Access form:

DoCmd.OpenReport ReportName, acViewPreview, , criteria, acWindowNormal
On Error Resume Next
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, ReportName, acSaveNo

This allowed the windows Print box to be displayed so that the user could
choose the appropriate printer and whatever print options he/she wanted.

Now that we are using Access 2007, these 4 lines of code work about 80% of
the time. The other 20% of the time, what prints out is a copy of the form
on the screen.

Has something changed? Is there other VBA code that I should be using
instead?

To anyone that help...Thanks!

Brian
 
B

Brendan Reynolds

Try selecting the report using DoCmd.SelectObject. Here's an example ...

DoCmd.OpenReport ReportName, acViewPreview, , criteria,
acWindowNormal
DoCmd.SelectObject acReport, ReportName
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, ReportName, acSaveNo
 

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