Results 1 to 9 of 9
  1. #1
    Gan is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    8

    Question How to send a report to a pdf file using code

    I am trying to send the output from a report to a pdf file that I will name but I can't seem to get it working:
    I am using this simple command that is associated with the click event of a command button:
    DoCmd.OutputTo acOutputReport, "CE7" , acFormatPDF, "testFile.pdf"

    The name of the report is CE7 and the name of the pdf file to output is testFile.pdf.
    I am getting the following error. The report works fine. Is the above syntax correct. What am I missing?


    Thanks for your feed back


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    I don't see anything wrong with the syntax, works for me. However, you don't specify the full destination file path. The code works but do you know where the file will end up? I found mine in C:\Temp and I don't know why, maybe because it was the last folder I was in.

    Image in your post is not showing.
    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
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Welcome to the forum.....

    You didn't specify what the error message is.

    Help says that the outputfile is: "A string expression that's the full name, including the path, of the file you want to output the object to."

    Instead of "testFile.pdf", try adding the drive and path -> "C:\MyFolder\testFile.pdf" (or whatever path you need)

  4. #4
    Gan is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    8

    Still can't figure out why it does not work for me

    Quote Originally Posted by June7 View Post
    I don't see anything wrong with the syntax, works for me. However, you don't specify the full destination file path. The code works but do you know where the file will end up? I found mine in C:\Temp and I don't know why, maybe because it was the last folder I was in.

    Image in your post is not showing.
    I have attached the error.
    Doc1.pdf

    Thank you for taking the time out to reply. I really appreciate it.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Sorry, that doesn't help explain why you get error. I still don't see anything wrong with the code.

    However, as stated, you should use a full folder/file path.
    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.

  6. #6
    Gan is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    8
    It is more a mystery why the same code works on your computer but does not work on mine. I used the fully folder/file path. Here is the code:
    Private Sub Command20_Click()
    Dim FileName As String
    FileName = "c:\CeDownload\pdf\ReportA.pdf"
    DoCmd.OutputTo acOutputReport, "ce7", acFormatPDF, FileName
    End Sub

    Thank you again for your help.

  7. #7
    Gan is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    8
    Ignore my previous post - I was able to get it to work after re-creating the function from scratch. The generated error message suggests a problem with the function name: The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]

    Thank you for your help.

  8. #8
    Gan is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    8
    A followup question to my previous post -
    I want to save each of the report form generated with the name associated with the account number field of each record that meets a criteria. Currently, this

    Private Sub Command20_Click()
    Dim FileName As String
    FileName = "c:\CeDownload\pdf\ReportA.pdf"
    DoCmd.OutputTo acOutputReport, "ce7", acFormatPDF, FileName
    End Sub

    works with all the reports save as one pdf file. I need a single pdf file saved for each record of the file with the name matching the account number of each of the records.
    Any help will be greatly appreciated.
    Thank you.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    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. Replies: 21
    Last Post: 08-20-2012, 11:59 PM
  2. Replies: 2
    Last Post: 08-05-2012, 06:32 PM
  3. Send Report to a NEW file
    By alyon in forum Access
    Replies: 9
    Last Post: 12-06-2011, 12:57 PM
  4. Help Send Report to File.
    By alyon in forum Access
    Replies: 4
    Last Post: 08-22-2011, 10:37 AM
  5. HELP! how to send data from table to text file
    By daveofgv in forum Import/Export Data
    Replies: 11
    Last Post: 02-14-2011, 01:22 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