Changing Sub-Form Based on Data in Main Form

thethack

Registered User.
Local time
Today, 07:07
Joined
Sep 7, 2001
Messages
13
I want to have a different sub-form based on the contents of a combo field (response in combo field is limited to a list) in my parent form. I have 8 possible options for the combo field and depending on the option chosen, I want the sub-form's Source Object to change.

The combo field in the parent is "combo89" and the sub-form object in the parent is "child115". In the combo89 properteries under the Event Tab I have an event procedure in the After Update field. The event procedure is this:

Private Sub Combo89_AfterUpdate()
If Me.Combo89.Value = "2" Then
Me.Child115.SourceObject = "STISets1"
ElseIf Me.Combo89.Value = "3" Then
Me.Child115.SourceObject = "STIHealth1"
ElseIf Me.Combo89.Value = "4" Then
Me.Child115.SourceObject = "STIDistrictSets1"
ElseIf Me.Combo89.Value = "5" Then
Me.Child115.SourceObject = "STIDistrictHealth1"
ElseIf Me.Combo89.Value = "6" Then
Me.Child115.SourceObject = "STIDistrict1"
ElseIf Me.Combo89.Value = "7" Then
Me.Child115.SourceObject = "STIState1"
ElseIf Me.Combo89.Value = "8" Then
Me.Child115.SourceObject = "STIEnrollment1"
Else
Me.Child115.SourceObject = "STIOffice1"
End If
End Sub

I do not typically use code so I am sure I am leaving out a few things. Any advice?
 

Users who are viewing this thread

Back
Top Bottom