Printing Report

  • Thread starter Thread starter Ayo
  • Start date Start date
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.
 
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
 
Thanks fredg. I tried that also but got the same problem. I figured it out
though. This does the trick:

DoCmd.RunCommand acCmdPrint
 
Back
Top