Results 1 to 11 of 11
  1. #1
    Aaron5714 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    48

    Export embedded report to PDF

    I have pasted a link below to a database I am working on that tracks contract documents. I am having some trouble trying to export a report that is emedded in a form using the BrowseTo method (I believe this feature is new in Access 2010 so it may not work in earlier versions).

    Click the "Report Center" tab, then click the "Active Agreements" link on the left side of the page. Select the first option on the pop-up window ("Select a Category"), click OK, then on the next window select "Category 1" in the drop-down menu and click OK.

    The "rptActiveContractsByLocation" report will load using the BrowseTo method. On the bottom of the report I added a link to export to PDF. This link uses the DoCmd.OutputTo method and saves a PDF of the report on the user's desktop.

    Here is the problem: the PDF report that is generated shows all records; it is not the filtered report that is displayed on the screen. I would like to have a link or button the user can click if they want to export the exact report displayed on screen with the filters applied.

    Any help would be greatly appreciated.



    Here is the sample database: http://dl.dropbox.com/u/65832352/Exa...Database.accdb

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I believe the problem is that the report is not open as an independent object that the OutputTo method can recognize so it finds it in the Navigation pane list and outputs the report which is not filtered. Referencing the embedded report would mean referencing through the levels of the navigation form it is buried in. I am doubtful the OutputTo method can handle this.
    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
    Aaron5714 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    48
    Thanks for your input; I assumed that was the issue. Any ideas for a work-around? My users like the embedded reports feature rather than having reports open in separate tabs or windows, however they also need to be able to export them.

    Would it be possible to have a link on the embedded report that opens a copy as an independent object (in a new window/tab, possibly hidden), and then runs the OutputTo method, then closes the window? Let me know what you think.

    Thanks again!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    That is the approach I would take. Code opens the report in ReportView, runs OutputTo, and closes. The procedure can happen so fast, the users might barely see a flash on the screen.

    I don't use Tabbed Documents, I use Overlapping Windows, in my db setup.
    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
    Aaron5714 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    48
    I tried editing the link at the bottom of the report so that it would open the embedded report in a new window, using the DoCmd.OpenReport method, however I am still having trouble referencing the filtered report that is displayed on the screen rather than the report from the navigaition pane.

    Any advice on how to write the VBA statement so that is will open the embedded report displayed on screen (with the filters applied) in a new window?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    So the report would be open as embedded in the form and also as an independent object? Opening multiple instances of same object is not easy. I have seen code that does it for forms.

    Review http://allenbrowne.com/ser-35.html
    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
    Aaron5714 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    48
    Here's a thought: Once the report has been generated by the user and is embedded in the Report Center form, is there a way to read the filter property of that embedded report? If so, I think I can just run the standard DoCmd.OpenReport and pass those filter values in the Where Condition, then when the report is open in a new window I can run the OutputTo method to generate a PDF.

    I know how to read the filter property of a report that is an independent object (not embedded), but I'm not sure how to do it when the report is embedded within the levels of the navigation subform. I'm guessing I would have to reference a path like this: frmMain > NavigationSubform > frmReportCenter > rptActiveContractsByLocation however I'm not sure of the exact syntax.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Can read the RecordSource or Filter properties of subform/subreport - I do that with normal form/subform that is built with Container Control. You are using a Navigation form. Referencing the embedded report would mean referencing through the levels of the navigation form it is buried in and I don't know the syntax for that. I've tried to help another poster figure that out and gave up. I've never used navigation form.
    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
    Aaron5714 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    48
    Ok, thanks for your input. I will keep experimenting and see if I can figure it out.

  10. #10
    Aaron5714 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    48
    Looks like I figured this out. I was able to read the filter property of the embedded report with a simple "Me.Filter". When the user clicks the "Export to PDF" link on the embedded report it runs the code below. This opens the report as an independent object using the OpenReport method and using Me.Filter (i.e. the filters currently applied on the embedded report) as the where condition, then it runs OutputTo to generate a PDF of the filtered report, then finally is closes the new window that was opened by OpenReport.

    Code:
    Private Sub txtExport_Click()
        DoCmd.OpenReport "rptActiveContractsByLocation", acViewReport, , Me.Filter, acWindowNormal
        DoCmd.OutputTo acOutputReport, "rptActiveContractsByLocation", acFormatPDF, "C:\Users\" & (Environ$("Username")) & "\Desktop\ActiveContractReport.pdf"
        DoCmd.Close acReport, "rptActiveContractsByLocation", acSaveNo
        Beep
        MsgBox "Report export complete. File saved to:" & Chr(13) & "C:\Users\" & (Environ$("Username")) & "\Desktop\ActiveContractsByCategory.pdf"
    End Sub

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Having the link on the report instead of some level above the report does make it easier. Interesting that two instances of report is allowed with regular code. Maybe it's just forms that require special handling.

    Glad you figured it out, congratulations!
    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: 4
    Last Post: 05-17-2012, 04:11 PM
  2. Replies: 1
    Last Post: 02-09-2012, 11:33 PM
  3. Report Export to Excel
    By BLD21 in forum Import/Export Data
    Replies: 1
    Last Post: 05-06-2011, 10:19 AM
  4. Export report to jpg
    By isdm in forum Reports
    Replies: 1
    Last Post: 04-16-2010, 10:00 PM
  5. Access Report and embedded images
    By joypanattil in forum Reports
    Replies: 0
    Last Post: 11-22-2008, 03:50 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