开发者

an access problem:OutputTo not work in access 2007

i Have used this code in access 2010 for genrating pdf file DoCmd.OutputTo acOutputReport, "Graph_report2", ".pdf", "C:\Graph_report2.pdf", True

it is working fine in access 2010 but when i ope开发者_如何学JAVAn my access database in access 2007 it gives Runtime error 2501 that 'The OutputTo action was cancelled' and not pdf file is open.

Big problem !what i do? Plz Help


DoCmd.OutputTo acOutputReport, "Graph_report2", ".pdf", "C:\Graph_report2.pdf", True

should be:

DoCmd.OutputTo acOutputReport, "Graph_report2", acFormatPDF, "C:\Graph_report2.pdf", True

Rob


Can I add that apart that one needs to install an add in for PDF output and then start Access 2007, http://www.microsoft.com/en-us/download/details.aspx?id=9943

If one tries to save the file in a directory that does not exist, this error will also pop up.

Here is a function for PDF output:

    Function PrintToPDF(SrcReport As String, DestPath As String, DestFile As String, ShowPdf As Boolean)
    On Error GoTo PrintToPDF_Err

    'ScrReport = The report Name to output as PDF
    'DestPath = Destination path for PDF file e.g. C:/DatabaseReports/Financial/
    'DestFile = File name for the PDF file being created, but without the file extension, one can add date to it
    'Showpdf = launch pdf viwer and display this PDF output

    DoCmd.OutputTo acOutputReport, SrcReport, "PDFFormat(*.pdf)", DestPath & DestFile & ".pdf", ShowPdf, "", 0, acExportQualityPrint

  PrintToPDF_Exit:
    Exit Function

  PrintToPDF_Err:
    MsgBox Error$
    Resume PrintToPDF_Exit


   End Function
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜