Slow loading sub-forms

R

RL

Good afternoon,

I have a form with 10 sub-forms each with its own tab. Depending on the
amount of records in the main form, the form can take up to ten seconds to
load – seemingly not displaying anything until all data has been retrieved
for all 10 sub-forms (even though only one is in view at any time).

I hope to reduce the load time by displaying the whole form as soon as the
visible tab’s data has loaded. Then to either:
- Load the remaining hidden data in a pre-determined sequence.
- Or load other tab data as and when the corresponding tab is selected.

Are either of these alternatives possible? If so, how?

Thanks in advance,
RL
 
J

Jeanette Cunningham

Hi RL
The tab control has a Change event.
Use this event to tell the tab control which subform to load.
The form will load a lot quicker if it only has to load one subform at a
time.

To leave a subform control empty, you simply go to the subform control and
remove the name of its source object.

To show the correct subform when the tab control is on that page, you tell
the subform control which subform to use as its source object and you may
need to tell it what to use for the link master and child fields.

You know which page of the tab control currently is open or has the focus by
looking at the value of the tab control.
When the tab control is on the first page it has a value of 0, on the second
page it has a value of 1, etc.

So code looks something like this-->
(My tab control is called TabA - use the correct name for your tab control.
Replace the obvious names with your object names.)

Private Sub TabA_Change()
Select case Me.TabA
Case 0
Me.NameOfSubformControl.SourceObject = "NameOfTheSubformForPage0"

Case 1
Me.NameOfSubformControl.SourceObject = "NameOfTheSubformForPage1"

Case 2
Me.NameOfSubformControl.SourceObject = "NameOfTheSubformForPage3"

End Select
End Sub

You can set up the tab control so that none of the subforms are in their
SubformControls.
When the form loads, you can tell it to call the sub TabA_Change to set up
the subform for whichever page of the subform you want to open when the form
loads.

Each time the user clicks on a different page of the tab control, the sub
called TabA_Change will run and set up the correct subform for that page of
the tab control.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
R

RL

Perfect. Really simple and reduced the load time to a fraction of what it was.
Thank you, thank you, thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top