Form with changing SubForm

rgreene

Registered User.
Local time
Today, 04:55
Joined
Jan 22, 2002
Messages
168
I have a form with a Subform. On the form there is a drop down category field. I want the subform to change depending on the category that is picked.
For instance on the form if you pick the category "Vehicle" then the "Vehicle SubForm" displays as the subform. If you pick "Electronics" then the "Electronics Subform" displays.
Is this possible?

I'm new to Access and VB so the more detailed the reply the more hair I get to keep.

Thanks in advance!!
 
Yes this is possible:

change the subforms controls Source Object to the name of the SubForm that you want on the selection of the catagory. You may need to reset Parent/Child relationships when you do this.
 
How do I tell the control source to be what ever is chosen in the Category field. I looked at the control source and it listed the form I've already created. I didn't see how to do anything other than pick a form.
 
The "Source Object" is a property of the SubForm Control. Simply set it equal to the other forms that you want based on the selection.


On the AfterUpdate event of the control you do the selection:

Me.[YourSubFormControlName].SourceObject="Your Form Name"


You can use an IF...ELSEIF...END IF or a SELECT CASE statement to decide the forms name:

Select Case Me.[Option Button]
case 1: stForm="This SubForm"
case 2: stForm="That SubForm"
End Select

Me.[YourSubFormControlName].SourceObject=stForm
 

Users who are viewing this thread

Back
Top Bottom