conditional choice of subform

  • Thread starter Thread starter george
  • Start date Start date
G

george

Hi to all,

I have a main form with a combo box and a tab control on
it.

On pg3 of the tab control there is a subform. What I would
like to do is to have a different subform appear on pg3
depending on the value of the combo box on the main form.

Example: if the value for the combo box is "Automobile" I
would like the fsubAutomobile to appear on pg3 whereas if
the value for the combo box is "Bicycle" I would like the
fsubBicycle to appear on pg3 of the tab control.

(Note: the two subforms share different info and different
number of fields, it would not suit me to just change the
rowsource for the same subform)

Is this possible?
 
Yes it is.
On the AfterUpdate of your main form combo, you can apply a different query
to the RecordSource of the subform.

Check out Record Source Property/Examples in Help, and it will show you how
to apply a query/SQL statement to a subform. Then just use an IF to decide
which query/SQL to apply.
hth
Al Camp
 
Al,
thanks for the reply. I don't really understand this. What
about the subform's design? If fsubAutomobile has a
different look than fsubBicycle, where are their different
designs stored in the solution that you propose? I thought
I should already have the different subforms made and
then somehow manage to substitute one for the other
programmatilly with conditional expressions
 
Hi George,

You should be able to do this by manipulating the SourceObject and
perhaps also the LinkChildFields and LinkMasterFields properties of the
subform control on the tab page. A subform is merely a form that has
been opened in a subform control, and the SourceObject property of the
subform control determines which form it opens.

An alternative approach would be to have two subform controls on the
tab, and make one or the other visible as needed.
 
Back
Top