Form with changing SubForm

rgreene

Registered User.
Local time
Today, 17:01
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!!
 
You mean you use only one subform, but want to show diff record groups depending on the criteria in the combo?

Both categories are kept in one table?

If so, you'll need only one subform, but change the subform record source based on the category combo box.

Post the SQL of the subform query, so I can tell you more.
 
changing subforms
Hi

I have done something similar by using this code behind the main form.

Private Sub Form_Current()

Select Case Me!category
Case "electronics"
Me.sfrmwhatever.SourceObject = "frmelectronics"

Case "vehicle"
Me.sfrmwhatever.SourceObject = "frmvehicle"


End Select

Me!sfrmwhatever.requery
End Sub

On your main form, use the name of the subform to replace "sfrmwhatever", and where I have put "frmelectronics", "frmvehicle", replace with the actual form names you have given them.
Category will be whatever you called your drop down box.

HTH
 

Users who are viewing this thread

Back
Top Bottom