OutputTo & 2046 Error - Revisited

MCOwen

Programmer
Local time
Today, 12:37
Joined
Aug 11, 2007
Messages
5
I've looked through the past threads and none seemed to provide any insight to my situation. I'm new to the OutputTo command. I first tested it with a standalone macro. Once working, I created some code to execute the macro from a form with the database window hidden. The macro worked fine. I then have tried to run the command from vba (so that I may easily alter the output location and file name on the fly). I'm stuck on the 2046 error. Thinking there might be a problem with the variable stDocName, I tried the the report name as a quoted string -- still get the error.

Application.Echo False
DoCmd.Hourglass True
HideDatabaseWindow False
' DoCmd.RunMacro "OutPutRTF"
DoCmd.OutputTo acOutputReport, stDocName, _
acFormatRTF, _
"D:\Office Developer Projects\DatabaseApplication\Devlp_mdb\Access2002\Version3.x\Expenses.rtf"
Application.Echo True
HideDatabaseWindow True
DoCmd.Hourglass False
 
Bob,

Thanks for the info. Unfortunately I've not been able to get either to work in my case. I get a message that the database can not be opened because its open in exclusive mode by another user. I have the databased open in shared mode.

I still don't understand why the RunMacro works while the Docmd.OutputTo does not. In stepping through my code, I can see that the database window has been made visible prior to the execution of the Docmd.OutputTo.
 
Try putting me.setfocus just above the docmd.output command.
 

Users who are viewing this thread

Back
Top Bottom