Dynamically Switched Subforms

Blake

Registered User.
Local time
Today, 10:05
Joined
Aug 28, 2002
Messages
21
Is it possible to dynamically change a form's subform content? I'd like my main form to have an option group which lets the user choose one of several lookup options, each option corresponding to a different subform having data entry fields in which the user enters various lookup parameters. If there are three lookup options, I'll need three different subforms, each having appropriate lookup parameters for that option. If the user clicks option button 1, she'll see subform 1; if she clicks option button 2 then subform 1 will disappear and subform 2 appears in its place, etc. This should avoid a lot of opening/closing of forms, as the user tries to decide which lookup option to use. Is the foregoing technique practical? If it is, I'd appreciate any development hints. If it's impractical, I'd appreciate suggestions for a practical alternative.

Regards, Blake R. Wiggs
 
I prefer a tabbed form for this but you can create the main form and stack three subforms on top of each other with their visible properties set to No. Then use the option group to make one form visible and all the other forms hidden.

Me.Sub1.Visible = No
Me.Sub2.Visible = No
Me.Sub3.Visible = No
Select Case Me.YourOption
Case 1
Me.Sub1.Visible = True
Case 2
Me.Sub2.Visible = True
Case 3
Me.Sub3.Visible = True
End Select
 
You wrote
<<
Is it possible to dynamically change a form's subform content?
>>

Yes.

On a main form you will add a subform control, call it "subSubformContainer".
The subform control has a property called SourceObject. You can refer to this property in an event sub.

For example, create an option group with two buttons, call it "optSubform".
Make an AfterUpdate event procedure for the option group. In the event sub you would enter:
If Me![optSubform]=1 Then ' they chose subform one
Me![subSubformContainer].SourceObject = "subfrmOne"
Else 'they chose subform two
Me![subSubformContainer].SourceObject = "subfrmTwo"
EndIf

RichM
 
Thank you both for your helpful suggestions. After doing some experimentation, I've settled on Pat's tabbed form suggestion as simplest. Indeed, despite having tabbed forms staring me in the face via several applications developed by others, I've never had time to try them. They do appear to be the best fit for my situation.

Regards, Blake R. Wiggs
 

Users who are viewing this thread

Back
Top Bottom