I'm using Access 2016 and have created a report from a query with a parameter request. Is there any way to add a button to export the report to PDF? Or a Print button?
I'm using Access 2016 and have created a report from a query with a parameter request. Is there any way to add a button to export the report to PDF? Or a Print button?
Do you mean you have a dynamic parameterized query as report RecordSource? This is a parameter input popup? I NEVER use dynamic parameterized queries and definitely not with input popup.
Yes, buttons can have code to export or print. This would use the OpenReport and OutputTo and maybe even PrintOut methods. However, the input popup might cause issues.
I use VBA to set report WHERE CONDITION argument when report is opened.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
June, so instead of creating a query with [parameter], you create a report off of the table with a Where Condition argument. Is this correct? If so, I need to research how to do this. I also have tried to code a few buttons but nothing has worked for PDF'ing or printing the report. One was close, but made the query parameter window pop open again. And still wouldn't print.
Report direct to printer like:
DoCmd.OpenReport "reportname", , , "ID=" & Me.cbxID
Code to open report and export to pdf like:
DoCmd.OpenReport "reportname", acViewPreview, , "ID=" & Me.cbxID
DoCmd.OutputTo acOutputReport, "", acFormatPDF, "mypath/" & Me.cbxID & ".pdf", False
DoCmd.Close acReport, "reportname", acSaveNo
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.