Changing Subforms

  • Thread starter Thread starter rony
  • Start date Start date
R

rony

I would like to write a form using MS Access xp that loads a different
subform onto the main form, depending on data selected in a combo box. How
can I do this?

Many thanks


Rony
 
I would like to write a form using MS Access xp that loads a different
subform onto the main form, depending on data selected in a combo box. How
can I do this?

Use the AfterUpdate event of the combo box:

Private Sub comboboxname_AfterUpdate()
Select Case Me!comboboxname
Case "This"
Me!subMySubform.SourceObject = "ThisForm"
Case "That"
Me!subMySubform.SourceObject = "ThatForm"
Case Else
<do something appropriate>
End Select
End Sub

Note that the subMySubform here is the name *of the subform control*;
by default, Access gives the control the same name as the form within
the control. That's not what you want in this case!

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Back
Top