Accessdatabase print report to PDF via command button

I have an access database. I have a form with command buttons to print a report. When I click on the command button I am prompted for "CoID". CoID is an auto number. After I enter the CoID number my report prints. Is there a way to print the report to PDF vs. printing on my printer? Or can I get the option to print or PDF?

Thank you.

Conernesto
ConernestoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
CoID is an auto number.

 Something in the report (a control, sort and group option, etc) or query that the report is based on, is referring to ColD

  It's also possible that it's simply mis-spelled.....should it not be ColID rather than ColD?

  If the report is based on a query, trying opening the query on it's own.  If your not prompted, then the problem is in the report.   If it truly needs ColD, then add it to the query.

Is there a way to print the report to PDF vs. printing on my printer? Or can I get the option to print or PDF?

 When you open the report, specify PDF:

                DoCmd.OutputTo acOutputReport, "rptMyReport", acFormatPDF, strFileName

 and give a file name.

Jim.
0
ConernestoAuthor Commented:
Hi,

I believe the command button has below. How would I change the code to print PDF?

Private Sub EFT_Approval_Form_Click()
On Error GoTo Err_EFT_Approval_Form_Click

    Dim stDocName As String

    stDocName = "EFT by CoID Rev_rpt"
    DoCmd.OpenReport stDocName, acNormal

Exit_EFT_Approval_Form_Click:
    Exit Sub

Err_EFT_Approval_Form_Click:
    MsgBox Err.Description
    Resume Exit_EFT_Approval_Form_Click
End Sub
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
DoCmd.OutputTo acOutputReport, "EFT by CoID Rev_rpt", acFormatPDF, "EFTbyCoIDRev_rpt.PDF"

 in place of:

    stDocName = "EFT by CoID Rev_rpt"
    DoCmd.OpenReport stDocName, acNormal

Jim.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Sorry, needs to be this:

                stDocName = "EFT by CoID Rev_rpt"
                DoCmd.OpenReport stDocName, ", acViewPreview, , , acHidden

                DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF,  "EFTbyCoIDRev_rpt.PDF"

                'close the report
                DoCmd.Close acReport, stDocName
0
ConernestoAuthor Commented:
Hi,

I crated a simple database with a table named Table1_tbl. I also created a form and report. The Form name is Table1_frm and the Report name is Table1_rpt. Please open Table1_frm and click on the command button named Print Report (on the button of the form. I now have the option of printing to PDF or my regular printer. It seems that the default is PDF which is what I wanted. Attached is the simple database. To get the option to print to PDF, I added the command button.

So I think we are done with this one.
Blank1-12-9-2015.accdb
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Are you all set then?

Jim.
0
ConernestoAuthor Commented:
It worked.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Printers and Scanners

From novice to tech pro — start learning today.