?
Solved

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

Posted on 2014-12-30
4
Medium Priority
?
128 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 52

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 38

Accepted Solution

by:
PatHartman earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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…
Suggested Courses

777 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