Source Object..

  • Thread starter Thread starter Mike C
  • Start date Start date
M

Mike C

I would like the source object of my sub form to change
based on an option the user selects. Here is some code I
set up in an on click event of one of the options.

Main Form: frm_Main_Detail
Sub Form : frm_Detail

The two sub forms I would to switch around
are "frm_OS_Detail" and "frm_INT_Detail". Any help or
suggestions would be appreciated and thanks in advance.

Private Sub op_os_Click()
op_os.Value = True

If op_os.Value = True Then
op_int.Value = False
End If

Dim frm As Form
Set frm = [Forms]![frm_Main_Detail]![frm_Detail]

frm.SourceObject = "frm_OS_Detail"

End Sub
 
Mike C said:
I would like the source object of my sub form to change
based on an option the user selects. Here is some code I
set up in an on click event of one of the options.

Main Form: frm_Main_Detail
Sub Form : frm_Detail

The two sub forms I would to switch around
are "frm_OS_Detail" and "frm_INT_Detail". Any help or
suggestions would be appreciated and thanks in advance.

Private Sub op_os_Click()
op_os.Value = True

If op_os.Value = True Then
op_int.Value = False
End If

Dim frm As Form
Set frm = [Forms]![frm_Main_Detail]![frm_Detail]

frm.SourceObject = "frm_OS_Detail"

End Sub

Close, but not exactly. The SourceObject property belongs to the
subform *control* on the main form, which is a control, not a form. If
"frm_Detail" is the name of this control, then your code would be

Forms!frm_Main_Detail!frm_Detail.SourceObject = _
"frm_OS_Detail"

or, if this code is running on form frm_Main_Detail, just

Me!frm_Detail.SourceObject = "frm_OS_Detail"
 
That did it, thank you very much.


-----Original Message-----
Mike C said:
I would like the source object of my sub form to change
based on an option the user selects. Here is some code I
set up in an on click event of one of the options.

Main Form: frm_Main_Detail
Sub Form : frm_Detail

The two sub forms I would to switch around
are "frm_OS_Detail" and "frm_INT_Detail". Any help or
suggestions would be appreciated and thanks in advance.

Private Sub op_os_Click()
op_os.Value = True

If op_os.Value = True Then
op_int.Value = False
End If

Dim frm As Form
Set frm = [Forms]![frm_Main_Detail]![frm_Detail]

frm.SourceObject = "frm_OS_Detail"

End Sub

Close, but not exactly. The SourceObject property belongs to the
subform *control* on the main form, which is a control, not a form. If
"frm_Detail" is the name of this control, then your code would be

Forms!frm_Main_Detail!frm_Detail.SourceObject = _
"frm_OS_Detail"

or, if this code is running on form frm_Main_Detail, just

Me!frm_Detail.SourceObject = "frm_OS_Detail"

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 
Back
Top