Results 1 to 8 of 8
  1. #1
    rrciesla is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Dec 2014
    Posts
    9

    Save report as PDF with name derived from report filed

    Hello,



    I have a report (Purchase Order) that needs to be saved as a PDF. I put a button on the report to do this but I would like the PDF to automatically draw it's name from the PO Number field on the report and save it to c:\Purchase Orders folder. Can this be done?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Yes. Reference field. Are you using OutputTo command? Show your code.

    Button won't work on report in PrintPreview.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,523
    vRpt ="InvestRpt " & Me.Code 'This is the name I want to call my file
    vFile = "c:\folder" & vRpt & ".pdf"
    docmd.OutputTo acOutputReport ,"rMyReport",acFormatPDF,vFile

  4. #4
    rrciesla is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Dec 2014
    Posts
    9
    June7, I don't code. Not a programmer. I am building this database using the visual tools. Can I send you a copy? It's about 11 mg.

  5. #5
    rrciesla is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Dec 2014
    Posts
    9
    June7, I have compact/repaired and compressed the file. I appreciate your help.
    Attached Files Attached Files

  6. #6
    rrciesla is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Dec 2014
    Posts
    9
    ranman256,

    I inserted the code you suggested with changes. I changed "InvestRpt" to "PurchaseRpt", Me.code changed to me.PO_Number (PO_Number is the field from which I want to draw the file name.) I changed the "c:\folder" to the folder I want to save to.
    Now when I click the Save to PDF button I get an error that says "Run-time error '2059' Cannot find object '|1'."
    Any suggestions?

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    You have button on form, not report.

    You have to code in something - either macros or VBA. You appear to be using macros. I don't use macros.

    Set the OutputFile argument to:
    Code:
    "C:\Purchase Orders\" & Forms![Purchase Order View by PO number_f]![PO Number] & ".pdf"
    That should work but isn't for me. VBA does work:
    Code:
    Private Sub Save_PDF_Click()
    DoCmd.OutputTo acOutputReport, "PO Report by PO number", acFormatPDF, "C:\Purchase Orders\" & Me.[PO Number] & ".pdf"
    End Sub

    Data structure is wrong. Should not have multiple tables for ChangeOrders, Contracts, Customers, Employees, Labor, Purchases, Sales, Vendors. Why do you do this?


    Strongly advise not to use spaces nor punctuation/special characters (underscore only exception) in naming convention.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    rrciesla is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Dec 2014
    Posts
    9
    June7,

    That works. Thank you so much. The reason for the multiple tables is I don't know any better. But this works for my needs.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 11-16-2019, 02:05 AM
  2. Using name from filed as a report file name
    By XP_2600 in forum Reports
    Replies: 2
    Last Post: 02-27-2017, 04:54 AM
  3. Replies: 3
    Last Post: 06-23-2015, 12:23 PM
  4. Replies: 2
    Last Post: 04-21-2015, 11:33 AM
  5. Replies: 6
    Last Post: 12-12-2011, 09:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums