I am developing an Access 2007 "project" (.ADP) as a front-end to a SQL Server 2005 Express database.
Several of my Access Reports get printed then successfully saved as a PDF file using the following VBA code :
DoCmd.OpenReport strReportName, acViewNormal, , , , strOpenArgs
DoEvents
If Not genAllBlanks(strArchiveFile) Then
DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, strArchiveFile
End If
DoCmd.Close acReport, strReportName
Howver, I have been stumped all day on this with a new Report that I am creating! My report "prints" OK, but the PDF file just does not get created. In fact, I don't think the Sub Procedure in which this happens is being completed because I do not get a "Message Box" as it is exitted.
This Report is a very simple, single-page report and this type of code works OK with other more compicated reports that involve various fonts and graphics.
I read on one web-site that the PDF export function doesn't like too much VBA code in the Report, so I stripped all that out (there was a couple of calls to some SQL Server Stored Procedures) but that did not solve it. I have also changed the path name for my strArchiveFile variable but with no success.
Can anyone suggest why this technique which has worked for me over several years on much larger reports, be causing this problem?
Many thanks. Colin.
If Not genAllBlanks(strArchiveFil
If not, your report would never get to the OutputTo line. Try setting a breakpoint in your code, and then run the function that executes that code. You should be able to step through the code to determine exactly what is happening.
Another thing you can try is to export the report using the interface - open the report, and then use the Ribbon to export it to PDF. You'll often get errors there that may not surface in VBA.