Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box Run Macro Open Subform 1

Status
Not open for further replies.

shankel

MIS
May 19, 2003
37
US
I am trying to create a form with Combo Boxes that will display a different subform based on what the user chooses. Clicking the selection in the combo box would run a macro that would open up a different subform depending on what was clicked. Anyone have any ideas?
To the user it would look like a static frame at the top that would change the views below based on what was selected. The subforms would each be different query results.
 
Set all of the different subform's visible property to False.

Then you could lay the subforms on top of each other. Then in the AfterUpdate of the combobox, make the associated subform's visible property to True.

For Example;

If Me![ComboBox1] = "SubForm1" Then
Me![Form]![SubForm1].Visible = True
Me![Form]![SubForm2].Visible = False
Else
Me![Form]![SubForm2].Visible = True
Me![Form]![SubForm1].Visible = False
End If


[thumbsup2]


Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
It doesn't seem to do anything when I make my selection in the combo box. This is the code that I typed in.

Private Sub Combo23_AfterUpdate()
If Me![Combo23] = "Business Unit" Then
Me![Dashboard_subforms_tab]![qvApplication subform].Visible = True
Me![Dashboard_subforms_tab]![Child29].Visible = False
Else
Me![Dashboard_subforms_tab]![Child29].Visible = True
Me![Dashboard_subforms_tab]![qvApplication subform].Visible = False
End If
End Sub

Business Unit is one of the options in the combo box.
Dashboard_subforms_tab is the name of the form that the subform is in.
qvApplication is the name of one subform, and Child29 is the name of the other.
 
I am sorry, I left out "Form" in the Visible string your code should be:

Private Sub Combo23_AfterUpdate()
If Me![Combo23] = "Business Unit" Then
Me![Dashboard_subforms_tab]![qvApplication subform].Form.Visible = True
Me![Dashboard_subforms_tab]![Child29].Form.Visible = False
Else
Me![Dashboard_subforms_tab]![Child29].Form.Visible = True
Me![Dashboard_subforms_tab]![qvApplication subform].Form.Visible = False
End If

Good luck!

Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
Yikes!!! Looks like Monday has got me messed up. The Me!'s should be Forms!.

I believe that should do it, I'm not sure if I am helping or hrting you at this point!

[ponder]

Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
I started over with a different form, and it looks like it's trying to work, but something is wrong.

Access can't find the field Dashboard_subforms_tab
 
I appreciate your help, as I am not much of a coder.
I am getting an error now:

Compile error: Type Mismatch

If Forms![Combo23]
 
That's okay, looks like I am not one either:

The first Me! stays.

If Me![Combo23] = "Business Unit" Then
Forms![Dashboard_subforms_tab]![qvApplication subform].Form.Visible = True
Forms![Dashboard_subforms_tab]![Child29].Form.Visible = False
Else
Forms![Dashboard_subforms_tab]![Child29].Form.Visible = True
Forms![Dashboard_subforms_tab]![qvApplication subform].Form.Visible = False
End If




Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
Perfect! Thanks a lot for all of your help.
That's exactly what I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top