Results 1 to 9 of 9
  1. #1
    ekoziko is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Apr 2018
    Posts
    2

    Export Report To PDF

    For about a year now, I have been collecting data from machines around to plant. I have been exporting the report without issue since then. All of the sudden I am getting an error saying the format in which I am exporting is not supported 'error 2282'. This has me scratching me head because it has worked flawlessly for a year now. Below is the code where it gets hung up on. Any help would be greatly appreciated!

    Public Function Export_Report()
    Dim myPath As String
    Dim Myfilename As String


    DoCmd.Requery
    Me.Refresh
    'Exports the code to the location


    myPath = "G:\Electronic Sheets\Reports"
    Myfilename = "Spadone SOS Report.pdf"
    DoCmd.OutputTo acOutputReport, "Spadone_Reports", acFormatPDF, myPath & Myfilename, False, , , acExportQualityPrint
    End Function

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    If you did a debug.print on 'mypath & myfilename' you would see the problem
    Missing backslash between them. Add that and it should be fine

    Also what purpose do the requery and refresh lines have here?
    I think both could be removed
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    your path is invalid (missing backslash),
    EDIT:

    the forum will not post the last backslash...
    so IF your path has the backslash,
    and the entire path is correct, then it should work. I use it all the time.

    try:
    DoCmd.OutputTo acOutputReport, "Spadone_Reports", acFormatPDF, myPath & Myfilename

  4. #4
    ekoziko is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Apr 2018
    Posts
    2
    Quote Originally Posted by ridders52 View Post
    If you did a debug.print on 'mypath & myfilename' you would see the problem
    Missing backslash between them. Add that and it should be fine

    Also what purpose do the requery and refresh lines have here?
    I think both could be removed
    The purpose of those is to save the data in the form into the table before exporting the report. And looking at it, I do have the backlash, it just wont post in the forum. Its always worked up till now.

  5. #5
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    This should be definitive.

    Code:
    Public Function Export_Report()
    Dim myPath As String
    Dim Myfilename As String
    Dim MyFullPath as string
    
    
    DoCmd.Requery
    Me.Refresh
    'Exports the code to the location
    myPath = "G:\Electronic Sheets\Reports"
    Myfilename = "Spadone SOS Report.pdf"
    MyFullPath = myPath & Myfilename
    debug.print MyFullPath
    DoCmd.OutputTo acOutputReport, "Spadone_Reports", acFormatPDF, MyFullPath, False, , , acExportQualityPrint
    End Function

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Quote Originally Posted by ekoziko View Post
    The purpose of those is to save the data in the form into the table before exporting the report. And looking at it, I do have the backlash, it just wont post in the forum. Its always worked up till now.
    The forum glitch with the missing backslash is irritating and I forgot about it in your case.
    Suggest you check by adding the line
    Code:
    Debug.Print myPath & Myfilename
    before trying to export the PDF

    Otherwise, I also can't see anything wrong with your PDF export code

    The 'generic' error description for error 2282 is
    The format in which you are attempting to output the current object is not available.@Either you are attempting to output the current object to a format that is not valid for its object type, or the formats that enable you to output data as a Microsoft Excel, rich-text format, MS-DOS text, or HTML file are missing from the Windows Registry. Run Setup to reinstall Microsoft Access or, if you're familiar with the settings in the Registry, try to correct them yourself. For more information on the Registry, click Help.@@2@1@9015@1
    I suggest you repair or reinstall Access as it suggests

    However, on the other point, if your form is bound, the table is updated automatically
    If its unbound, this isn't how to do so.

    Requery is used to update the controls on a form after an update including those edited by other users in a multiuser environment.
    Refresh is similar but only for current user
    There are also repaint & recalc methods which again do similar things

    Have a read of these two links for a better explanation than I can do:
    https://support.office.com/en-us/art...5-a472e742366c
    http://www.projectperfect.com.au/blo...h-and-repaint/
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    @davegri, your code is also still missing the last slash. I am able to post last slash.

    Code:
    DoCmd.Requery
     Me.Refresh
     'Exports the code to the location
     myPath = "G:\Electronic Sheets\Reports\"
     Myfilename = "Spadone SOS Report.pdf"
     DoCmd.OutputTo acOutputReport, "Spadone_Reports", acFormatPDF, myPath & Myfilename, False, , , acExportQualityPrint
     End Function
    Go to Advanced Edit > uncheck the "Automatically parse links in text" in Additional Options below the edit window. Usually have to fiddle with it (sometimes type more than once, avoid typing anything else and not pressing Enter key) but manage to get posted eventually.

    Also, sometimes if I edit a post I have to uncheck the option again but I have edited this post several times without losing the backslash in this post. Even did a test of copy/paste the code from this post (includes the last slash) into this post and it retained the slash without unchecking the option (did another edit to remove the dup code). Also did a test of pasting just the myPath line outside CODE tags into this post and the slash was lost without unchecking the option. The item would have to be unchecked for a new post as the setting is not saved.
    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
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    This backslash issue does seem to be a fairly recent 'glitch'

    This is purely a test after unticking the option June mentioned
    Code:
    myPath = "G:\Electronic Sheets\Reports\"
    Here's another test using a link to see if it messes it up
    http://www.bbc.co.uk

    Assuming it works on both can I make the setting 'stick'?

    EDIT:
    Both worked perfectly - thanks June
    BUT the setting isn't permanent - you'd need to remember to untick each time

    If matrix reads this post, is it possible to solve the 'backslash problem' permanently?
    Last edited by isladogs; 04-06-2018 at 01:02 PM. Reason: Added results!
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  9. #9
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    @davegri, your code is also still missing the last slash. I am able to post last slash.
    That was the point. It was to point it out to the OP whether his code had it or not.

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

Similar Threads

  1. Export Report to PDF
    By Ganymede in forum Import/Export Data
    Replies: 2
    Last Post: 03-16-2016, 08:55 AM
  2. export report to excel
    By AMRI YULIANDI in forum Reports
    Replies: 4
    Last Post: 12-11-2014, 07:10 AM
  3. Export Report to PDF
    By cuddles in forum Reports
    Replies: 10
    Last Post: 05-21-2014, 09:28 AM
  4. export report
    By slimjen in forum Forms
    Replies: 7
    Last Post: 04-24-2013, 08:14 AM
  5. Export report to jpg
    By isdm in forum Reports
    Replies: 1
    Last Post: 04-16-2010, 10:00 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