How to export report to PDF with dates and cbo criteria?

tihmir

Registered User.
Local time
Today, 05:11
Joined
May 1, 2018
Messages
257
Hi, this is next step of my project - to export report (rpt_Inspections) to PDF with dates ("date from" and "date to") and cbo (cbo_Worker) filter.

How to write in VBA?
 
what version of Access do you have.
you can Print your report in PDF (A2007-A2019).
 
what version of Access do you have.
you can Print your report in PDF (A2007-A2019).
My version of Access is 2016.

I want the report not to be printed. Аfter pressing the button I want to save it to the pdf in the appropriate directory.
 
when your report opens, you can print/save it as PDF. check the ribbon.
 
Make a date from and date to on a form and configure your report to work between them, make a button with the following on-click event:

Code:
Private Sub Command25_Click()
On Error Resume Next
DoCmd.OutputTo acOutputReport, "ReportName", "PDFFormat(*.pdf)", , False, , , acExportQualityPrint
On Error Resume Next
End Sub
 
Make a date from and date to on a form and configure your report to work between them, make a button with the following on-click event:

Code:
Private Sub Command25_Click()
On Error Resume Next
DoCmd.OutputTo acOutputReport, "ReportName", "PDFFormat(*.pdf)", , False, , , acExportQualityPrint
On Error Resume Next
 End Sub


I have a date from and date to on a filter for, but when I press button "Save to PDF" it save all records, not just selected dates and workers.
Here it is....
 

Attachments

when the report opens, on the ribbon there is PDF or XPS.
you don't need another code just to export the current report.
 
There is an odd issue in access with filters and the like only working when you open the report, not when you export it. I would put the date from and to in the data source of the report as date betweens.

See attached
 

Attachments

when the report opens, on the ribbon there is PDF or XPS.
you don't need another code just to export the current report.
arnelgp, I saw this option on ribbon menu (PDF or XPS), but I want to be closed this menu in access. I want my workers just to press buttons, I mean to be
easiest for them
 
use docmd.RunCommand acCmdPrint
 
There is an odd issue in access with filters and the like only working when you open the report, not when you export it. I would put the date from and to in the data source of the report as date betweens.

See attached
That's work perfect, Tieval! Than you! Тhank you too arnelgp!
Now I notice there is only date filtering but i want to add and cbo filtering 2 criteria.
And now on pressing button "Report" the report open in Print Preview with this code: DoCmd.OpenReport strReport, lngView, , strWhere,
I want to open report in normal "ReportView" to add button

What I have to change in the code - DoCmd.OpenReport strReport, lngView, , strWhere ?
 
Last edited:
I only changed the date bit, if you look at the data source of the report you just need to change the other bit there.
 
I only changed the date bit, if you look at the data source of the report you just need to change the other bit there.
Yes, I added one more creteria cbo_Worker. Now the report has 2 criteria - date and cbo. Now it works perfect. Thanks again, Tieval
 

Users who are viewing this thread

Back
Top Bottom