OutputTo pdf error

K

Ken Warthen

I have a listview control on an Access 2007 form where users can select any
or all of a list of names who will be sent an email with a pdf certificate
attached. The pdf is an Access report. I'm using the following code and the
OutputTo line is generating an error number 2501 (The OutputTo action was
canceled). I can't figure out what I'm doing wrong. Here's the syntax of
offending line I'm using.

DoCmd.OpenReport "Professional Development Certificate", acViewPreview,
WindowMode:=acHidden, OpenArgs:=strOpenArgs
' The following line generates error
DoCmd.OutputTo acOutputReport, ObjectName:="Professional Development
Certificate", OutputFormat:=acFormatPDF, OutputFile:=strOutputFile


Any help or suggestions, would be greatly appreciated.

Ken
 
N

NKTower

I don't think that yu want to or can have the report open when you do the
OutputTo. I think it's one or the other.

That raises the issue of the use of OpenArgs - OutputTo doesn't provide an
OpenArgs formal argument.

Quick and dirty - pass the info in via a global variable

glb_MyOpenArgs = "blah blah blah"
DoCmd.OoutputTo ...

Purist - Open the report in design view, hidden, and change the recordsourc
property, or whatever else you were ttweaking. A little pseudo code...

Dim myRpt As Report
DoCmd.OpenReport "reportname", acViewDesign, ... acHidden
Set myRpt = Reports![reportname]
myRpt.recordsource = ......
myRpt.Controls("somelabel").Caption = "something"
etc.
DoCmd.Close acReport, "reportname", acSaveYes
Set myRpt = Nothing
DoCmd.OutputTo .....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top