Printing reports through VBA

  • Follow


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

0
Reply Utf 1/14/2008 6:23:01 PM

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

"Brian" <Brian@discussions.microsoft.com> wrote in message 
news:AC165D4A-CBF2-4F10-ACB3-FF7DD1632725@microsoft.com...
>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
>



-- 
Brendan Reynolds 

1
Reply Brendan 1/15/2008 11:15:43 AM

1 Replies
2945 Views

(page loaded in 0.067 seconds)


Reply: