How to Speed up opening a form

I have a form with two subforms: A and B. The SourceObject of each subform is set in the Open event of the main form. The first SourceObject assignmnet statement (for subform A) is executed in <1ms, but the second one (for subform B) takes 3-4 seconds.

If I switch the SourceObject assignment statements so that B is executed first and A is executed second, I get the same result; ie, the first (now for B) takes <1ms to execute, and the second (now for A) takes 3-4 seconds.

How can I make then both quick?
LVL 1
MilewskpAsked:
Who is Participating?
 
MilewskpConnect With a Mentor Author Commented:
Hi all,
It turns out it was network issues. In the course of running tests during the day, I found the speed would vary widely from minute to minute and hour to hour. The database has several tables that are linked to three or four different mdb files over the LAN. When I converted all of then to local tables, teh form opened in a jiffy. The interesting thing is that teh form is not dependent on any of these tables - I can delete then from teh database and the form still opens just fine.

This form became slow a week or two ago, and very likely will become fast again if the IT guys restore the network to its previuos configuration - I'm at their mercy.

The silver lining is that during my investigation I optimized the form's code which has helped.

Moral of my story:
If a form runs a lot faster when all linked tables have been converted to local tables, the network the tables are linked over is likely to blame. Linked tables can even affect the performance of a form that's not depend or related to them in any way.
The best you can do is optimize your form to run as fast as possible when all linked tables are converted to local tables. After that, you're at the mercy of the network.




0
 
RgGray3Commented:
Interesting...

Do they both retrieve large recordsets?  (Approx # or records)

It sounds like the first Query/filter must completely return its records before the second line of code assigning the second Source object is executed...

With the understanding that Percieved speed is as good as actual speed...
Do they both need to be viewed at the same time...  SIDE BY SIDE...

Could you place the two objects on seperate pages of a tab control...
It would HIDE the speed lag
0
 
GRayLCommented:
What happens if you hardcode the SourceObject's for each subform?
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
MilewskpAuthor Commented:
Hi RgGray3,
<Do they both retrieve large recordsets?>
Both subforms have the same recordsource (q500_Project), which has 833 records.
NOTE: the LinkChildFields and LinkMasterFields of both subforms is "" (zls).

<Do they both need to be viewed at the same time...  SIDE BY SIDE...>
Yes.

<Could you place the two objects on seperate pages of a tab control...>
No.
0
 
MilewskpAuthor Commented:
If I delete the Recordsource property of both subforms, the main form opens in a jiffy.
0
 
RgGray3Commented:
What is the reason for assigning the SourceObject at runtime  
0
 
MilewskpAuthor Commented:
Hi RgGray3,
<What is the reason for assigning the SourceObject at runtime?>
It's a practice of mine for all subforms.
I tried settign the SourceObject for both subforms in the design view of the main form, and got the same speed issue.
0
 
RgGray3Commented:
I do the same thing on Subforms on Pages of a tab control...
only the subform on the first page is hard coded...
This way I only load data when it is needed...   (JIT)
but that does not seem to be a solution for this problem

You stated that you have tried to connect the forms in design time and connect the data with similar results...

is it the visual lag that bothers you/your users or is the time really excessive?

Going back to percieved speed...
it is possible to open the form hidden or "freeze" the screen when you load the main form
Put up a little distraction "Loading Data"
After it is loaded unfreeze the screen and display the completely loaded form

What I suspect is your problem is that due to the way Access manages forms and their data...
It displays a form after the first page of data (screenfull) is loaded ...  but it continues to load the rest of the data before returning control to the user and program.

Hence your lag.
 Are you working on a slow network, is the data large and complex

Are you loading fields in your datasource that are not needed for display..   (Select * from ...  instead of Select Field1, Field2,Field3
or are their calculations in the query that could be performed by the form

Just a few thoughts
0
 
GRayLCommented:
If the first subform is driven by a query and the query takes 'some' time to complete, again a reason for the delay.  You can get an appreciation of the delay by running the query and noting the time it take for the record count to appear.
0
 
MilewskpAuthor Commented:
Hi GrayL,
<again a reason for the delay>
So why does the first subform take <1ms but the second one takes 3-4 sec?

<noting the time it take for the record count to appear. >
I'll try that and report back.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"A and B. The SourceObject of each subform is set in the Open event of the main form."
Have you tried using the On Load event of the main form ?

And ... did you answer the question @ http:#a34910915 ?

Because unless you employee that Tab control, with two tabs and a corresponding subform ... and then set the Source Object for the tab (page) that is not initially visible ... on-the-fly ... I'm not seeing any advantage of using the On Open or On Load events on the main form to set the Source Object of the subforms.  In fact, I can almost envision this as slowing down the process.

mx
0
 
MilewskpAuthor Commented:
Hi mx,
<Have you tried using the On Load event of the main form ?>
No. why would it make a difference?

<I can almost envision this as slowing down the process.>
I  tried settign the SourceObject for both subforms in the design view of the main form, and got the same speed issue.

Hi GRayL
<What happens if you hardcode the SourceObject's for each subform?>
I  tried settign the SourceObject for both subforms in the design view of the main form, and got the same speed issue.
(Sorry, I didn't see your post before.)





0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"I  tried settign the SourceObject for both subforms in the design view of the main form, and got the same speed issue."

"why would it make a difference?"
My point is ... since this is no difference, why bother with code to set in Open event ?

mx
0
 
GRayLCommented:
Given the query takes some time to execute, you might improve the processing speed if large tables are involved by making sure you have a primary key on each table and the appropriate fields are indexed.  
0
 
MilewskpAuthor Commented:
Hi GrayL,
<noting the time it take for the record count to appear. >
I tried that; the record count appears in about 2-2.5 seconds.
0
 
MilewskpAuthor Commented:
Hi GaryL,
When I open the subforms directly, it takes about 3-4 seconds for the record count to appear.
0
 
GRayLCommented:
I believe that is why the delay in opening the second subform.  If you are running a query with an ORDER BY clause, make sure the fields in the clause are indexed if one or more large tables are involved.  Depending on the complexity of the query, large could be as few as 10,000 to 100,000 records.
0
 
GRayLCommented:
In addition, if you are running off a server,  your network speed is going to impact your query processing time.
0
 
MilewskpAuthor Commented:
Thanks everyone for trying to help. I will chose my answer as the solution.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"The best you can do is optimize your form to run as fast as possible when all linked tables are converted to local tables"
Not exactly a revelation ...
0
 
MilewskpAuthor Commented:
.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.