Solved

Send report to user's desktop seems to take quite a while

Posted on 2014-12-30
4
123 Views
Last Modified: 2014-12-30
I'm using the following code to send a report to the user's desktop but it seems to take quite a while.  Is there a faster method?

    DoCmd.OpenReport "Report", acViewPreview, , "[InterviewID]=" & Me.txtInterviewID, acHidden
    DoCmd.OutputTo acOutputReport, "Report", acFormatPDF, "\\" & Environ("userProfile") & "\Desktop\" & Me.txtUserID & ".pdf", , , , acExportQualityPrint
    DoCmd.Close acReport, "Report"

Open in new window

0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 37

Expert Comment

by:Neil Russell
ID: 40523614
Where is the report run?
How big is it?
0
 
LVL 51

Expert Comment

by:Rgonzo1971
ID: 40523627
Hi,

A way to do this, without opening the report, is to base the report on a query which references a control on a form (maybe Me.txtInterviewID), as a parameter.

Regards
0
 

Author Comment

by:SteveL13
ID: 40523631
The report is run from a command button on a form.  It is made up of the Main Report as well as two sub-reports.  I don't know if this might be a clue but the main report, in addition to the field data coming from the record source, has five field that are DLookup fields.  One of the sub-reports also has five DLookup fields.
0
 
LVL 37

Accepted Solution

by:
PatHartman earned 500 total points
ID: 40523817
First step is to get rid of the DLookup()s.  You can almost certainly replace them with joins to the lookup tables.  You may need to use left joins if the fields are optional.

Second step is to do what Rgonzo1971 suggested and that is to change the main report's RecordSource query to get InterviewID from the form.

Select ....
From ...
Where InterviewID = Forms!yourform!txtInterviewID;

The biggest problem is the dlookup()s.  Each one runs a separate query and because you are opening the report first and then sending it to the .pdf, they are each running twice.  If you have 1,000 detail items in the report and there are 10 DLookup()s, that is 10,000!!!! queries that have to be run and then run AGAIN when you output to the PDF.

So once you have made the changes to the query, you can eliminate the openReport method and just use the OutputTo method.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question