472,986 Members | 2,906 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,986 software developers and data experts.

Speeding Up Reports

I am running a complex query using about 25 criteria that are entered
on a query form. If any individual criteria isn't required its field is
left as "*" on the form. When I run the query the first time the
results take about 3 or 4 seconds to appear on a "Query Results" form.
Subsequent queries using either the same or different criteria give a
result in less than 1 second.

The "Query Results" form has a button to open an equally complex report
(about 30 fields) based on the same query as the form. The report takes
about 20 seconds to open in print preview each time. What is Access
actually doing when a report is being generated and why will the query
results display on a form so much more quickly than on a report?

Is there anything I can do, other than simplify the query, to reduce
the time that the report takes to open?

Thanks in advance.

Nov 13 '05 #1
2 1581
What Access is doing is to rerun queries into your original query, based on
the sorting and grouping that it must perform within the report.

Instead of including all those criteria in the original query when you may
only need to use a few of the 25 or so, could you leave them out of the
query? Instead, generate a WhereCondition for your OpenReport, based only on
the text boxes that have a value. This should dramatically reduce the number
of criteria that Access has to evaluate to get the report open, and it may
even facilitate the use of indexes (depending on the specifics).

The example below shows how to build up a WhereCondition string from only
the text boxes where the user entered a value. It is coded in such as way as
to make it easy to add as many conditions as you need.

---------------code starts------------------
Dim strWhere As String
Dim lngLen As Long

If Not IsNull(Me.txtFilterCity) Then 'Text field example.
strWhere = strWhere & "([City] = """ & Me.txtFilterCity & """) AND "
End If

If Not IsNull(Me.txtFilterAmount) Then 'Number field example
strWhere = strWhere & "([Amount] = " & Me.txtFilterAmount & ") AND "
End If

'etc for other boxes.

'Now cut off the trailing " AND ".
lngLen = Len(strWhere) - 5
If lngLen > 0 Then
strWhere = Left$(strWhere, lngLen)
End If

DoCmd.OpenReport "Report1", acViewPreview, , strWhere
---------------code ends------------------
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Wayne" <cq*******@volcanomail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I am running a complex query using about 25 criteria that are entered
on a query form. If any individual criteria isn't required its field is
left as "*" on the form. When I run the query the first time the
results take about 3 or 4 seconds to appear on a "Query Results" form.
Subsequent queries using either the same or different criteria give a
result in less than 1 second.

The "Query Results" form has a button to open an equally complex report
(about 30 fields) based on the same query as the form. The report takes
about 20 seconds to open in print preview each time. What is Access
actually doing when a report is being generated and why will the query
results display on a form so much more quickly than on a report?

Is there anything I can do, other than simplify the query, to reduce
the time that the report takes to open?

Thanks in advance.

Nov 13 '05 #2
Thanks Allen, I'll give this a try.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Snyke | last post by:
Hi. I have a command line script which works really fine, the only problem is that it take *really* long for the first output to be printed on screen. Since I also get some HTTP headers I'm...
5
by: BStorm | last post by:
I have a transaction log file where the DataSet table's Description column is actually delimited into "subcolumns" based upon the transaction id. I would like to parse these into separate fields...
12
by: dvumani | last post by:
I have C code which computes the row sums of a matrix, divide each element of each row with the row sum and then compute the column sum of the resulting matrix. Is there a way I can speed up the...
9
by: mfyahya | last post by:
Hi, I'm new to databases :) I need help speeding up select queries on my data which are currently taking 4-5 seconds. I set up a single large table of coordinates data with an index on the fields...
2
by: Robert Wilkens | last post by:
Ok... This may be the wrong forum, but it's the first place I'm trying. I'm new to C# and just implemented the 3-tier Distributed application from Chapter 1 (the first walkthrough) in the...
2
by: OHM | last post by:
I was wondering about this topic and although I accept that different situations call for different solutions, but wondered are there any other solutions and whether has anyone carried out a...
2
by: B.Newman | last post by:
I've got some VB.NET code that *should* get a list of reports from an Access MDB and populate a list box with them. It doesn't detect any of the reports at all. oAccess.Reports.Count comes up as...
5
by: RobinAG | last post by:
Hello, I just split my database into front and back end. My front end users are experiencing really slow opening of forms. I've searched online for help speeding up forms, but I'm not sure what...
10
by: ags5406 | last post by:
I've created an application that downloads data daily from a secure web site and stores that data in an Access database. Then there are different options for allowing the user to do keyword and...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.