Error 2046 on DoCmd.OutputTo (1 Viewer)

highandwild

Registered User.
Local time
Today, 15:20
Joined
Oct 30, 2009
Messages
435
Hi

I am outputing a report to PDF using the following line of code:

DoCmd.OutputTo acOutputReport, strReport, "PDFFormat(*.pdf)", strOutput, False, "", , acExportQualityPrint

where strReport and strOutout contain the name of the report and the name of the resultant pdf file.

It works fine when the Navigation Pane is visible but when I hide it I get error 2046.

This is a known error but is there a way around it short of showing the navigation pane?

I use the following code to hide the pane, how do I show it and how would I just minimise it?

DoCmd.SelectObject acTable, strTable, True
DoCmd.RunCommand acCmdWindowHide

Thanks



 

rctjoe24

Registered User.
Local time
Today, 10:20
Joined
Jul 9, 2012
Messages
28
Had to register just to offer this solution since I found it on another developer site.

Try putting me.setfocus before the docmd.outputto command.

For my scenerio, i was attempting to output three reports to PDF, then use another routine to automatically merge those PDFs. It would not output the first one at run time of an Access 2007 accde only as an accdb entering the db with Shift. After adding me.setfocus before each output command, the reports seemed to run.

I was :confused: then I was like :banghead:, but now I'm like :cool:
 

vbaInet

AWF VIP
Local time
Today, 15:20
Joined
Jan 22, 2010
Messages
26,374
What is the error message? Are you sure the error actually highlights that line of code?
 

bikermo

Registered User.
Local time
Today, 07:20
Joined
Jan 8, 2013
Messages
38
Had to register just to offer this solution since I found it on another developer site.

Try putting me.setfocus before the docmd.outputto command.

For my scenerio, i was attempting to output three reports to PDF, then use another routine to automatically merge those PDFs. It would not output the first one at run time of an Access 2007 accde only as an accdb entering the db with Shift. After adding me.setfocus before each output command, the reports seemed to run.

I was :confused: then I was like :banghead:, but now I'm like :cool:

and THANK YOU for doing so because this solved a problem i posted but no one has offered a solution to yet. you're the best!
 

MaxTorque

Registered User.
Local time
Today, 15:20
Joined
Dec 14, 2016
Messages
13
Had to register just to offer this solution since I found it on another developer site.

Try putting me.setfocus before the docmd.outputto command.

For my scenerio, i was attempting to output three reports to PDF, then use another routine to automatically merge those PDFs. It would not output the first one at run time of an Access 2007 accde only as an accdb entering the db with Shift. After adding me.setfocus before each output command, the reports seemed to run.

I was :confused: then I was like :banghead:, but now I'm like :cool:

Like Bikermo, I am very grateful for your simple solution to a frustrating problem. Thank you
 

Users who are viewing this thread

Top Bottom