I have two subform (subfrmA and subfrmB)and a main form frmAB. Both subforms are invisible until the user selects what form they want from comboboxAB on the main form. So if user selects Form A in the main form comboboxAB, subfrmA will become visible while subfrmB remains invisible. Then user inputs changes saves and exits.
But when the form is opened back up, I want the forms of the saved records to automatically load so I wrote the below code.
Private Sub Form_Load ()
If Me.comboboxAB.Text = “Form A” Then
Me.subfrmA.Visible = True
Me.subfrmB.Visible = False
Me.subfrmA.SourceObject = “Form.Form A”
ElseIf Me.comboboxAB.Text = “Form B” Then
Me.subfrmB.Visible = True
Me.subfrmA.Visible = False
Me.subfrmB.SourceObject = “Form.Form B”
End If
End Sub
However, I get an error. “Run-time error ‘2185’: You can’t reference a property or method for a control unless the control has the focus.”
And the code:
If Me.comboboxAB.Text = “Form A” Then
Is highlighted does anyone know why this is? Also I typed the code up on my tablet, so the quotes in my code look like smart quotes but they are not.