Select Report and Save as PDF

Novice1

Registered User.
Local time
Today, 09:59
Joined
Mar 9, 2004
Messages
385
My goal is to pull a report based on the record I'm working in then to save it as a pdf. I know how to pull a report while in the record ...

DoCmd.OpenReport stDocName, acNormal, , "[CaseNumber] =" & Forms!frmCases!CaseNumber

... but I don't know how to incorporate the [CaseNumber] into the Outputto code ...

DoCmd.OutputTo ObjectType:=acOutputReport, ObjectName:="rptAssignmentRIP", _
OutputFormat:=acFormatPDF, OutputFile:="C:\temp\RIP.pdf"
 
Can't directly. Simplest is probably to open the report filtered in preview mode (can be hidden), output to PDF, then close the report.
 
Not sure I understand. I already have a filter on the report ... [ReloID] = Forms!frmPCSTracker!ReloID ... shouldn't that filter be used when the report is generated?

How do you hide?

DoCmd.OpenReport "rptAssignmentRIP", acViewPreview

DoCmd.OutputTo ObjectType:=acOutputReport, ObjectName:="rptAssignmentRIP", _
OutputFormat:=acFormatPDF, OutputFile:="C:\temp\RIP.pdf"
 
Yes, you'd keep the wherecondition in your code but switch to preview. If you type commas after that you should see the argument that allows you to hide it. Or look at help on OpenReport. Don't forget to close the report after outputting.
 
Thank you ... it's working!!

DoCmd.OpenReport "rptAssignmentRIP", acViewPreview, , , acHidden

DoCmd.OutputTo ObjectType:=acOutputReport, ObjectName:="rptAssignmentRIP", _
OutputFormat:=acFormatPDF, OutputFile:="C:\Users\Public\Documents\SignInPlus\Relocations\Resources\AssignmentRIP.pdf"

DoCmd.Close acReport, "rptAssignmentRIP"
 
Happy to help, but didn't you want the filtering too?
 

Users who are viewing this thread

Back
Top Bottom