From: Ken Warthen on 11 Nov 2008 15:54 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
From: NKTower on 11 Nov 2008 19:57 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 ..... "Ken Warthen" wrote: > 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
|
Pages: 1 Prev: Cascading List Boxes Next: cmd button to open small form when value is null |