Link to home
Start Free TrialLog in
Avatar of Milewskp
MilewskpFlag for Canada

asked on

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?
Avatar of RgGray3
RgGray3

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
What happens if you hardcode the SourceObject's for each subform?
Avatar of Milewskp

ASKER

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.
If I delete the Recordsource property of both subforms, the main form opens in a jiffy.
What is the reason for assigning the SourceObject at runtime  
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.
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
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.
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.
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
"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
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.)





"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
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.  
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.
Hi GaryL,
When I open the subforms directly, it takes about 3-4 seconds for the record count to appear.
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.
In addition, if you are running off a server,  your network speed is going to impact your query processing time.
ASKER CERTIFIED SOLUTION
Avatar of Milewskp
Milewskp
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks everyone for trying to help. I will chose my answer as the solution.
"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 ...
.