Printing Report

A

Ayo

I have a print button on a form. I want the user to be able to click on this
button to print a report. I used these lines of code but nothing happens:

Private Sub cmdPrintReport_Click()
DoCmd.SelectObject acReport, "CV_AC Summary", True
DoCmd.PrintOut , acSelection
End Sub

I don't know what it is I am doing wrong. Any help will be greatly
appreciated.
Thank you.
 
F

fredg

I have a print button on a form. I want the user to be able to click on this
button to print a report. I used these lines of code but nothing happens:

Private Sub cmdPrintReport_Click()
DoCmd.SelectObject acReport, "CV_AC Summary", True
DoCmd.PrintOut , acSelection
End Sub

I don't know what it is I am doing wrong. Any help will be greatly
appreciated.
Thank you.

Did you read the arguments of the PrintOut method in VBA help?

acSelection refers to a selected portion of the selected object (which
would not be applicable to an Access report).
If you wish to print the entire report the argument is acPrintAll.
Also, as it's the first argument, there is no preceding comma (and
also as it is the default argument, if you omitted it that's the
argument you would automatically get):

DoCmd.SelectObject acReport, "CV_AC Summary", True
DoCmd.Printout acPrintAll
 
A

Ayo

Thanks fredg. I tried that also but got the same problem. I figured it out
though. This does the trick:

DoCmd.RunCommand acCmdPrint
 

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

Similar Threads


Top