• Print Report as PDF (Access2003)

    Author
    Topic
    #453075

    Good Monday everyone!
    I am pressing the button, Report gets generated and now I need to have it saved in C: in PDF format.
    I have Distiller and set referrenses to it.

    I use to use DoCmd..and it worked.

    So far the simpliest I found is

    Dim sCaption as String
    sCaption = “SomeFileName.pdf”

    DoCmd.OpenReport “ReportName”, acViewPreview, “Filter”, “Where Clause”

    Reports!ReportName.Caption = sCaption

    DoCmd.PrintOut

    DoCmd.Close

    However this one is not finding the name of the Report…which is there.
    I am assuming something is missing. I do not get this “Filter”, “Where Clause”

    I would appreciate simple one liner code.
    Seems like it is not used anymore, everytihng got too complex.

    And if possible, please, when Report is blank due to the wrong parameters selected – I would like a message ‘Please, select correct parameters’

    Much appreciate your helping me.

    Viewing 0 reply threads
    Author
    Replies
    • #1120572

      You shouldn’t use the Filter argument unless you want to the report to be filtered using the same criteria as a saved query.
      The WhereCondition argument can be used to specify the filter criteria directly, it should be something of the form

      "Amount > 1000"

      or

      "LastName Like 'A*'"

      YOU will have to determine what “wrong” parameters are.

      • #1120573

        Oh, no! I don’t HAVE to use this code.
        I was looking for the DoCmd.PrintOut and couldn’t find it.
        I found this one as a simpliest yet.

        I am still searching for the DoCmd.Print as PDF and stuff…

        thanks

        • #1120576

          You have to set the printer to PDF, something like

          Dim prtOldPrinter As Printer
          ‘ Save current printer
          Set prtOldPrinter = Application.Printer
          ‘ Set Acrobat as default printer
          Set Application.Printer = Application.Printers(“Adobe Acrobat”)
          ‘ Print report
          DoCmd.PrintOut
          ‘ Restore original printer
          Set Application.Printer = prtOldPrinter

    Viewing 0 reply threads
    Reply To: Print Report as PDF (Access2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: