Solved

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

Posted on 2014-12-30
4
109 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
4 Comments
 
LVL 37

Expert Comment

by:Neil Russell
Comment Utility
Where is the report run?
How big is it?
0
 
LVL 48

Expert Comment

by:Rgonzo1971
Comment Utility
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
Comment Utility
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 34

Accepted Solution

by:
PatHartman earned 500 total points
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now