Results 1 to 11 of 11
  1. #1
    MelonFuel is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2012
    Posts
    28

    How Do I Save/Print Report Save As A PDF And A Fieldname

    Hi Guys



    Need Some guidance here. I know this has been posted before but the ones ive tried haven't seemed to of worked for me.

    I tried using macros to save a .pdf and output to file but thats not what im after.

    Basically what I'm after is a button that you user can press on the report and it will:

    1 *Print it Off*
    2 *Save it to a folder on the server*
    3 *Save the file as the value inside of the OrderID text field which is normally one letter and 5 numbers but they will always be different.

    4 I also need it to display when the report is open and on the print it needs to be invisble.
    5 *Also it needs to be saved as a .PDF*

    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Review

    https://www.accessforums.net/import-...ges-25042.html

    I found that the report must open for the OutputTo method to work.

    For item 3, you want to save the name of the file just saved as PDF? Is the OrderID field included in the form's record source? Maybe simply:
    strFileName = some code here to generate the filename
    Me!OrderID = strFileName
    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
    MelonFuel is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2012
    Posts
    28
    Thanks for the reply.

    The post that you have linked looks promising but i have only just recently started using vba so it will take me some time to figure out, and thanks for the starting point.

    Any more help would be much appreciated.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Attempt code and when you encounter issue, post for analysis. Maybe this article will be helpful: http://office.microsoft.com/en-us/ac...010341717.aspx
    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.

  5. #5
    MelonFuel is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    28
    This is my code on the button on the report.

    Private Sub Command250_Click()
    Dim myPath As String
    Dim strReportName As String
    DoCmd.OpenReport "rptOrder", acViewPreview, , "[OrderID]=" & Me![OrderID], acWindowNormal

    myPath = "G:\Users Home\Myusername\"
    strReportName = [OrderID] & " " & [rptOrder] & ".pdf"
    DoCmd.OutputTo acOutputReport, "rptOrder", acFormatPDF, myPath + strReportName, True

    DoCmd.Close acReport, "rptOrder"

    End Sub

    I get a runtime error '2427' when i don't enter a value??

    i get a runtime error '2465' when i do enter a value??

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Code is behind a form or report?

    Enter what value?

    strReportName = Me!OrderID & " rptOrder.pdf"
    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.

  7. #7
    MelonFuel is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    28
    the code is behind a button on the report and if i enter 3, 6, 9999, a, b, fdsf it throws out those errors

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    What are those values for? Where are you entering them? Why are some numbers and some text? How do they pertain to the procedure?
    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.

  9. #9
    MelonFuel is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    28
    I'm not sure. It brings up a message box with the OrderID. The values (numbers and letters) don't mean anything. They don't i'm just trying to work out the code.

    EDIT:

    This code partly works

    Private Sub CreatePDF_Click()


    Dim myPath As String
    Dim strReportName As String


    DoCmd.OpenReport "rptOrder", acViewPreview


    myPath = "G:\Users Home\User\"
    strReportName = [OrderID]
    Format rptOrder.[OrderID], ".pdf"


    DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath + strReportName, True
    DoCmd.Close acReport, "rptOrder"


    End Sub

    But i get the runtime error '424'

    because of this line Format rptOrder.[OrderID], ".pdf"

  10. #10
    MelonFuel is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    28
    Edit new code

    Private Sub Command247_Click()
    DoCmd.OpenReport "rptOrder", acViewReport
    DoEvents
    DoCmd.OutputTo acOutputReport, "rptOrder", acFormatPDF, "G:\Users Home\user\rptOrder.pdf"
    End Sub

    Just need to save as the Value of OrderID E.G. C10045

    Plus just a quick question is there an option to email the report to an email address

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    That sounds like a query input parameter prompt. Do you want to provide project for analysis? Follow instructions at bottom of my post.
    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.

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

Similar Threads

  1. Print query records to reports and save as pdf
    By abhay_547 in forum Programming
    Replies: 0
    Last Post: 05-09-2011, 12:00 PM
  2. Replies: 9
    Last Post: 01-20-2011, 02:22 PM
  3. Print,save as and export option in report?
    By sunny in forum Reports
    Replies: 1
    Last Post: 07-27-2010, 09:55 AM
  4. Save report as pdf.
    By sams in forum Reports
    Replies: 7
    Last Post: 05-11-2010, 09:20 AM
  5. Replies: 1
    Last Post: 04-22-2010, 04:54 AM

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