Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228

    Report to PDF error

    When I press the button which triggers this code, the "output to " window does open. I can chose a network location and type the file name.

    Code:
    Private Sub Command26_Click()
     
    DoCmd.OpenReport "Quote_Main", acViewPreview
    DoCmd.OutputTo acOutputReport, "test", acFormatPDF, , True
    
    End Sub
    when I press ok I get the error:

    2059


    Microsoft accerss cannot find the object '|1'.

    This is the stripped down version of the code. I am able to open the report with this and view it.. I can then also manually export it from the ribbon, so I'm confused where the problem is. Any ideas?

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Does it happen when you choose a local location?


    Sent from my iPhone using Tapatalk

  3. #3
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Yes I'm just saving to my documents. I haven't tried to save elsewhere. (not in work right now to test)

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I am getting this same error when I try to save it to a location that I don't have write permission (even tho it looked like I should).

  5. #5
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Quote Originally Posted by Homegrownandy View Post
    Yes I'm just saving to my documents. I haven't tried to save elsewhere. (not in work right now to test)
    change the name of the report to remove the _

  6. #6
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    change the name of the report to remove the _
    Is it not the name of the report that is being opened (Quote_Main), or am I misunderstanding and you are not suggesting to remove the underscore from the name of the report being opened?

    I think either too much of the relevant code was not supplied, or an example of what name is being typed for the pdf version should have been provided. I seem to recall that this can fail with certain characters in a name for a pdf version while it will work for other formats. Or there is a similar problem with the file path chosen. OP might be using a file dialog folder picker and including extra quotes (or none where needed). And so on...
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    I managed to duplicate the error easily. But on changing the report name to quotemain (no underscore) the issue immediately resolved.


    Sent from my iPhone using Tapatalk

  8. #8
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Morning,

    I have renamed the report to QuoteMain. Also, the code pasted is the entire code in use. There is plenty more i want to use but currently this is the only code associated with the button:

    Code:
    Private Sub Command26_Click()
    
    DoCmd.OpenReport "QuoteMain", acViewPreview
    DoCmd.OutputTo acOutputReport, "strReportName", acFormatPDF, , True
    
    End Sub
    In the first example of code it would attempt to name the PDF "test". In this one it will be "strReportName". This will be a variable in the future but right now its just text.

    The file path is in my documents on my computer. If i manually create a PDF from the export ribbon then it does this with no problem.

  9. #9
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Are you still getting the same error?


    Sent from my iPhone using Tapatalk

  10. #10
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Just tried saving this to desktop, and also to the shared network drive. Still no joy.

    Edit: yes its the same error. on this line:

    Code:
    DoCmd.OutputTo acOutputReport, "strReportName", acFormatPDF, , True
    By this point the report is open.

  11. #11
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    The strreportname is a variable right? If so why is it in ""


    Sent from my iPhone using Tapatalk

  12. #12
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Another update:

    I thought maybe the data might be causing the error. Ive made a new report that has one text field from a table (no queries)

    Still get the same error.

  13. #13
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Quote Originally Posted by andy49 View Post
    The strreportname is a variable right? If so why is it in ""


    Sent from my iPhone using Tapatalk
    It not a variable now. Im trying to eliminate anything that could be causing it. The code supplied is the code im using (no variables.)

  14. #14
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Quote Originally Posted by Homegrownandy View Post
    It not a variable now. Im trying to eliminate anything that could be causing it. The code supplied is the code im using (no variables.)
    Code:
    DoCmd.OpenReport "QuoteMain", acViewPreview
    DoCmd.OutputTo acOutputReport, "", acFormatPDF, "h:\test.pdf"
    My latest version which works on my network

  15. #15
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Ive also just tried this in a new database. Still the same. I'll try this same code on a new machine when one is available.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Report Error
    By drunkenneo in forum Programming
    Replies: 2
    Last Post: 09-17-2013, 06:29 PM
  2. Error With Hyperlink In Report
    By Aaron5714 in forum Access
    Replies: 2
    Last Post: 08-02-2012, 11:42 AM
  3. Query OK Report Error
    By endri81 in forum Queries
    Replies: 1
    Last Post: 03-10-2012, 03:30 PM
  4. #Name? Error in Report
    By kristyspdx in forum Reports
    Replies: 4
    Last Post: 12-01-2011, 11:11 AM
  5. Report error
    By indira in forum Reports
    Replies: 2
    Last Post: 03-12-2011, 03:13 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