djh,
Yes, that code should work, but you may experience some difficulties if you are using Link Master and Link Child properties of the subforms and if those properties will need to be changed when you set the source objects.
If you are using a combo box to determine which subform to use, then...