Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print Report as PDF (Access2003)

    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.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print Report as PDF (Access2003)

    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
    <code>
    "Amount > 1000"
    </code>
    or
    <code>
    "LastName Like 'A*'"
    </code>
    YOU will have to determine what "wrong" parameters are.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Report as PDF (Access2003)

    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

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print Report as PDF (Access2003)

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •