Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open filtered report and save it as pdf 1

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
579
0
16
GB
Hello I have a form with btnReport
A report called rptCar

The unique I'd is CarId

Can someone help me with code to open the report to the current record that I am on and then save the report to my temp folder on my c drive as a pdf. In the process the PDFs should be named CarReport and the id number. Ie. CarReport1232

My efforts so far do not result in the report filtering. Thanks for any help. Mark.
 
If you open the report first there should be no issue in getting the filtered report. If you try to directly output it without opening you will need to change the sql of the report query first.

Code:
Public Sub ExportToPDF()
  Const strDir = "C:\"
  Const rptName = "rptCar"
  dim CarID as long
  carID = Me.carID
  DoCmd.OpenReport rptName, acViewPreview, , "CarID = " & CarID
  DoCmd.OutputTo acOutputReport, rptName, acFormatPDF, strDir & "CarReport" & CarID & ".pdf"
  DoCmd.Close acReport, rptName
End Sub
 
Thank you kindly. Happy new year 👍
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top