Solved

Access 2013: Use a make table query for faster report loads

Posted on 2014-09-12
7
813 Views
Last Modified: 2014-09-18
Have a legacy database am modernizing using a web database.  In testing, the desktop reports were running slow.  But they also run slow, when the data is local.  Just running that much slower, now.

Took apart the original reports until I found the culprit.  There are three sub-reports in the main report and once I removed them, report runs like lightning.  So the root cause to speed is the sub-report design, not the new web back end.

Found that make table queries are a much faster way of presenting data in sub-reports and very true.  Now that we have this method, the question is:  How to elegantly update the new local table, when running the report?
0
Comment
Question by:VirtualKansas
  • 4
  • 3
7 Comments
 
LVL 16

Expert Comment

by:Sheils
ID: 40320122
You can use a mismatch query to append the new records and an update query to update query to add new records.
0
 

Author Comment

by:VirtualKansas
ID: 40320148
I believe every word you're saying, just need more detail.  That and how to fire the query on report load, was in question.

Short version, make table query solved the speed issue; no just need data to be current on report load.
0
 
LVL 16

Accepted Solution

by:
Sheils earned 500 total points
ID: 40320190
I would use the following steps:-

Run the create table query when you first open the database. You can to that by using the onload even of the first form that opens when you load the database.

Then use the after update event of the form that you use to update records to run the update query
Use the after update event of the form that you use to add new records to run the append query.

The code will be something like:

Private Sub Form_AfterUpdate()

Dim strSQL as String

strSQL="your Update Query" & " where id=" & Me.YourIdfield

Currentdb.Execute strSQL


End Sub
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Closing Comment

by:VirtualKansas
ID: 40320213
My SQL skills aren't up to yours, but I get the gist and will take the answer on faith it can be done.  

I just got zinged by another limitation in my skill set in that it appears a make table query brings additional challenges when adding another table.  This will keep me occupied for the rest of the night before I can try your suggestion.  

In the mean time, thank you for quick response...
0
 
LVL 16

Expert Comment

by:Sheils
ID: 40320234
Instead of running a make table query all the time you can create a "temporary" table (tblTemp) with all the fields you need. Then run an append query when you load the database:

  SQL will be something like:

Insert Into tblTemp Select TableA.field1,TableB.field2 ....

Clear the temporary table when you close the database by using a delete query:

SQL:- Delete * From tblTemo
0
 

Author Comment

by:VirtualKansas
ID: 40328936
Sweet!  I applied your suggestion on append vs. make table.  

Cool that all I had to do was change the existing query from make table to append and point it at the existing table.  I manually deleted the records from the made tables, ran the append query and boom, all is as expected with the reports still running super fast as was the root of the exercise (the reports were slow, as sub-reports were querying all the fields in all the records from the original tables, vs. the limited set of fields in the new made tables.)

Now just to automate the delete and the append queries and should be back on track with no re-work of the reports needed!

TY
0
 
LVL 16

Expert Comment

by:Sheils
ID: 40329813
To automatically delete all records from the temporary table you can use a form on unload event.

You can use the event from a form that is always remain open while the database is in use. Alternatively, you can create an unbounded form (frmInvisible) and set it to invisible.

You can then use the onload event of the first form that opens when you open your database to open the invisible form. Code is:

Docmd.Open "frmInvisible"

Then in the unload event of the invisible form insert this code.

Dim strSQL as string
strSQL=Delete * FROM tblTemp
Currentdb.Execute strSQL

The invisible form will remain open and unseen while the databse is in use, When you close the database the invisible will close and in the proceed fire the unload event which will delete all records from the temp table
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Moving your enterprise fax infrastructure from in-house fax machines and servers to the cloud makes sense — from both an efficiency and productivity standpoint. But does migrating to a cloud fax solution mean you will no longer be able to send or re…
If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

708 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

14 Experts available now in Live!

Get 1:1 Help Now