Improving Query Performance

CPGDeveloper

Board Regular
Joined
Oct 8, 2008
Messages
157
Hi All ~

I administer an Access based application -- and since moving our back end to Azure SQL, our initial front end form is taking about 30 seconds to load. It took about 5-10 seconds when using a split MS Access Back End.

The Control Source of the subform that loads upon open changes depending on who is using the application. I have code that determines who is using the application, and based on who that is, generates a different sql statement to populate the control source. I then change the control source of the subform, and requery. I'm wondering if there's a simpler, faster way to achieve this --

When stepping through the code, where it slows down are these two statements --

Forms!fMain.subformMain.Form.RecordSource = mysql 'mysql is a sql statement that i've previously defined. It runs in one second when I run it directly as a query
Forms!fMain.subformMain.Requery

Both of these code lines take about 10-15 seconds each to generate. Everything else appears to be instant. Is there another way to write this. This is executed on the Form Load Event of the Primary Form.
 

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
880
If you change the record source of a form, that in itself is a requery, so no use repeating it, especially if the dataset is large?

If it is one used a lot, perhaps try using it as a saved query?

HTH
 

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,824
Office Version
  1. 2019
Platform
  1. Windows
5-10 seconds is also a long time (in the old split MSAccess BE). What is in this query?
 

CPGDeveloper

Board Regular
Joined
Oct 8, 2008
Messages
157
It's a SQL statement that is dynamically created depending on who the user is -- after some work on it, I created some views in SQL that load much much faster. Thanks for your help.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,467
Messages
5,624,913
Members
416,064
Latest member
PaulBr2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top