Access Subform Source object

ms-access, ms-access-2007, sql, vba

Solution

Your approach should work. I put a combo box named `cbxSubform` on my main form and added one line of code to its `AfterUpdate()` event handler...

Private Sub cbxSubform_AfterUpdate()
Me.mySubform.SourceObject = Me.cbxSubform.Value
End Sub

...and changing the selection in the combo box switches the subforms immediately. Are you sure that the `AfterUpdate()` code for your combo box is actually firing? (You could add a `MsgBox` or a `Debug.Print` to check.)

Problem

What I am trying to achieve is for a combo box (Combo_sf) selection to dictate the form in the subform control (sf_record) I have about 10 forms, their names are in the combo box data. I am new to VBA and am not sure if my approach is right: ``` Private Sub Combo_sf_AfterUpdate() Dim strLoadTable As String strLoadTable = "Form." & Me.Combo_sf.Value MsgBox strLoadTable Forms![frm_Mnu_Manage Configuration Settings]!sf_record.Form.SourceObject = strLoadTable End Sub ``` I have placed this in the combobox's after update event but when I make my selection nothing happens in the form. Am I approaching this right or would another way work better?

Original source