disabling the query to run on subforms when opening main form

  • Thread starter Thread starter AndréG
  • Start date Start date
A

AndréG

Hello,

I made a form (account number) containing a tab control with a subform on
every tab some of them are charts .... consequence: opening the main form
takes sometimes a lot of time especially if the data are accessed via the
network and the queries involve a lot of data.

I would like to disable the calculation of the subform until the specific
tab get's opened.

Does someone know how to do it.

I tried it by removing the recordsource value of the subform and dynamically
assigning a value to it when opening the tab but it would not work (the
charts are remaining empty and the subform's size and position get's
modified).
 
Set the Visible property of the subform control to No (False) as the default
setting in the main form's design view. When the subform control is
invisible, ACCESS usually won't load the subform's form's data at the time
of loading the main form. Then set the Visible property to Yes when you
click on the appropriate tab page.
 
I usually set the ControlSource property of the subform control to "" for
all of the tabs except the first one. I do this in the forms design view.

I then use the Tab controls (not individual tab pages) Change event, to set
the SourceObject of whatever tab is current. If it is blank, I set it to
the appropriate subform. It's been a while since I've needed to do this,
but as I recall, I also set the subform ControlSource properties to "" for
each of them in the forms current event (to prevent loading all of them when
you move to the next record). Then I set the tab controls value to 0 (first
page) and run the Change event. Something like:

Private Sub Form_Current

me.sub0.SourceObject = ""
me.sub1.SourceObject = ""
...
me.subN.SourceObject = ""
me.TabControlName.Value = 0
Call tabControlName_Change

End Sub

Private Sub TabControlName_Change

Select Case me.TabControlName.Value
Case 0
if me.sub0.SourceObject = "" then me.sub0.SourceObject =
"frm_Form0Name"
Case 1
if me.sub0.SourceObject = "" then me.sub0.SourceObject =
"frm_Form0Name"
Case ...
...
Case N
if me.subN.SourceObject = "" then me.subN.SourceObject =
"frm_FormNName"
End Select

End sub

HTH
Dale
 
Back
Top