开发者

Using "OutputTo" to create a report that has VBA code

I am using OutputTo to create reports, however my reports contain VBA code for styling and formatting, and when I use the OutputTo function it ignores my report-vba code.

My code:

DoCmd.OutputTo acOutputReport, "Report Name", acFormatSNP, "File Path", False
开发者_JAVA百科

Do you know any way to automatically create reports that will execute the report-vba code?

Thanks.


If you want the output to look exactly the same as the report viewed in Access, PDF is probably the best bet (thanks to iDevelop). However, depending on your version of Access, you may not be able to create a PDF with OutputTo, it only became available in the 2007 version. An alternative is to build your own html output, which can be quite pretty.


I ended up removing the VBA code that was used for styling and editing.


GD Aducci,

I was having same problem and solved the issue by removing the VBA in the report.

Whilst contemplating my succes I was wondering what might be the solution for the issue...

Mind you it's an idea, not a tried piece of code.

Here goes:

If you 'flag' the result of the formatting and styling VBA code in your report and make it into a boolean variable, you would be able to sample/retrieve the variable from your execution code. I.e. you would be able to retrieve the 'rendering-status' of the document.

You could then delay the actual execution of the 'OutputTo' routine by checking if all flags are 'true' if all come back as true, then formatting and styling should be finished and hence exporting to PDF would be optional, if they do not come back as 'true' then 'OutputTo' routine should be delayed even further.

It appears that 'OutputTo' just continues execution without actually confirming if document rendering has actually finished and hence ignores (and conflicts with) any VBA coding present in the document. So only option is to check if all code has executed before presenting the rendered document to the 'OutputTo' command ?

Perhaps code the 'OutputTo' as function and refer to it from the rendered document...?

As I said, I haven't coded it -yet- but it may be the solution ?

cheers !

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜