Solved

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

Posted on 2014-12-30
4
115 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 49

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 35

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

816 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

12 Experts available now in Live!

Get 1:1 Help Now