subform load order

F

Fredrated

I have a form with several subforms.
Is there any way to tell the form or subforms what order to load the
subforms, or is that only determined by the order in which the subforms were
added to the form?

Thanks

Fred
 
S

SteveM

First you need to understand that you have 'subform controls' on your form
not subforms. These 'subform controls' are containers for your subforms.

So, if you place subform controls on your form (from the Toolbox), you can
set the SourceObject property of those controls at run-time in the order you
wish.

You can also use one 'subform control' to display multiple subforms in the
same place by changing the SourceObject property. This is a better
alternative to stacking subforms since overlapping controls can give you
problems.

Steve
 
F

Fredrated

Indeed I have subform controls on my form.
The subforms referenced by these controls seem to load in the order that the
subform controls were placed on the form. Since some of my subforms refer to
data on other subforms it is important that the subforms within the controls
load in a specific order.

My question is, can the order the subforms are loaded into their controls be
specified in some way other than the order that the controls were created?

The question is moot now since I dropped all subform controls from the main
form, then recreated them in the order I need them to load. So the question
remains unanswered and is still interesting, though I have solved the problem
by recreating the subform controls.
 
S

SteveM

As you add controls to a form they receive the next Tab Order number. So, you
could just change the order of your subforms by changing their tab order.

Another way, that I explained before, is to set their SourceObject at
run-time using a form event, OnOpen for example...

Steve
 
T

Tammy

I am curious to know more about how to use one control for several subforms.
I have 4 subforms, but due to room on the main form, I only one to show one
at a time. I tried to layer the subforms and then in the "on click" property
I set a macro to RunCommand BringtoFront. But nothing happens when I click
on the subform. How can I get the user to pick the subform they want to use
first and then be able to click to load the next subform? I really don't
want to use popup forms.
 
S

SteveM

To be honest, the simplest way is to use a Tab Control and place each subform
on a different tab...

If you want to show several subforms in one place and control them from
code, you can use a single subform control and set its SourceObject property.
I do this when I am going to control the subform to display in code.

Let's say you have a subform control called MySubformControl and two forms
called frm1 and frm2.

Me.MySubformControl.SourceObject = "frm1" 'Displays frm1 in subform control
Me.MySubformControl.SourceObject = "frm2" 'Displays frm2 in subform control

So you can do that with buttons or based on the outcome of an expression in
code.

For design purposes, you can select the forms in the subform control's
property sheet and set it to the default form you want to show.

Steve
 
J

John W. Vinson

I am curious to know more about how to use one control for several subforms.
I have 4 subforms, but due to room on the main form, I only one to show one
at a time. I tried to layer the subforms and then in the "on click" property
I set a macro to RunCommand BringtoFront. But nothing happens when I click
on the subform. How can I get the user to pick the subform they want to use
first and then be able to click to load the next subform? I really don't
want to use popup forms.

Use a Tab Control on your form, and put one subform on each page of the
control.

John W. Vinson [MVP]
 
T

Tammy

thank you -- tab control worked wonderfully.

SteveM said:
To be honest, the simplest way is to use a Tab Control and place each subform
on a different tab...

If you want to show several subforms in one place and control them from
code, you can use a single subform control and set its SourceObject property.
I do this when I am going to control the subform to display in code.

Let's say you have a subform control called MySubformControl and two forms
called frm1 and frm2.

Me.MySubformControl.SourceObject = "frm1" 'Displays frm1 in subform control
Me.MySubformControl.SourceObject = "frm2" 'Displays frm2 in subform control

So you can do that with buttons or based on the outcome of an expression in
code.

For design purposes, you can select the forms in the subform control's
property sheet and set it to the default form you want to show.

Steve
 
Top