Output to PDF

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Output to PDF

Post by D Willett »

Hi. I have my K2K Report working and outputting as a pdf. Can I prevent the pdf report opening once it has been created?
This is to be an automated task, which will open the database as a scheduled task, the opening event will fire the code to create the report but I don't want the pdf report to open, silent task you see.

Code: Select all

Private Sub Form_Open(Cancel As Integer)
DoCmd.SetWarnings False
DoCmd.OpenQuery "mkJCV", acViewNormal, acEdit
DoCmd.SetWarnings True

'DoCmd.OpenReport "K2K-Summary", acPreview, "", "", acNormal
DoCmd.OutputTo acOutputReport, "K2K-Summary", acFormatPDF, "L:\mmpdf\MMDocs\Bodyshop Info\K2K-Summary" & ".pdf", True
DoCmd.RunCommand acCmdExit
End Sub
Cheers ...

Dave.

User avatar
HansV
Administrator
Posts: 78393
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Output to PDF

Post by HansV »

Change True at the end of the DoCmd.OutputTo line to False, or omit it (including the comma preceding it). It is the AutoStart argument that specifies whether the output file should be opened.
Best wishes,
Hans

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: Output to PDF

Post by D Willett »

Aaah. I thought it was the overwrite.. as the report will over write a previous version every time. Is there another argument for this?

Cheers
Cheers ...

Dave.

User avatar
HansV
Administrator
Posts: 78393
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Output to PDF

Post by HansV »

When you use DoCmd.OutputTo, an existing file will always be overwritten silently, without asking. If you would like to check if the file already exists, you have to do so yourself before calling DoCmd.OutputTo.
Best wishes,
Hans

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: Output to PDF

Post by D Willett »

Thats absolutely fine Hans.. thanks once again.

Cheers
Cheers ...

Dave.