Solved

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

Posted on 2014-12-30
4
118 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
ID: 40523614
Where is the report run?
How big is it?
0
 
LVL 50

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 36

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

828 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