Set Subform at runtime?

T

Tom

Using Access 2002 is it possible to change a forms subform at runtime so
that if a checkbox 1 on the main form is ticked Subform A is used, however
if checkbox 2 is ticked, Subform B is used.


TIA

Tom
 
T

TC

A form does not really "have a subform". A form has one or more subform
/controls/, each of which has a form in it.

Say that a main form frmMain, has a subform /control/ ctlSub, and you
want to change the form in that subform control, to frmNew:

me![ctlSub].sourceobject = "frmNew"

You might also need to reset the linkmasterfields and/or
linkchildfields properties of ctlSub. Try it & see.
 
T

TC

PS. So you would add an AfterUpdate event for the checkbox. That event
will fire whenever the user ticks or clears the box. Your code (in that
event) would just see what value the checkbox now had, then use the
statement that I gave you, to load the desired form into the subform
control.
 
Top