Solved

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

Posted on 2014-09-12
7
832 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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

Don't lose your head updating email signatures!

Do your end users still have the wrong email signature? Do email signature updates bore you or fill you with a sense of dread? You can make this a whole lot easier on yourself by trusting an Exclaimer email signature management solution. Over 50 million users do...so should you!

Question has a verified solution.

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

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
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…

920 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

16 Experts available now in Live!

Get 1:1 Help Now