In that case, you only need to use the TabControl_Change Event to see which
TabPage you are on, check whether the SourceObject has been set or not and
if it is not, assign the appropriate Form as the SourceObject. Assuming
that you set the SourceObject for the Subform on the first TabPage
(TabControl value = 0)only, then the code should be soomething like:
********
Private Sub tcLeft_Change()
On Error GoTo tcLeft_Change_Err
Application.Echo False, "Processing ..."
With Me
Select Case tcLeft
Case 0 ' First TabPage
' Do nothing. SourceObject loaded.
Case 1 ' Second TabPage
If .sfrOnSecondPage.SourceObject <> "TheFormToBeUsedAsTheSubform"
Then
.sfrOnSecondPage.SourceObject = "TheFormToBeUsedAsTheSubform"
End If
Case 2 ' Third TabPage
' Similar code
Case 3
' ...
Case 4
' ...
' ...
End With
tcLeft_Change_Exit:
On Error Resume Next
Application.Echo True
Exit Sub
tcLeft_Change_Err:
Select Case Err.Number
Case 0
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf &
vbCrLf & _
"(Programmer's note: Form_frmProduct_View.tcLeft_Change)", _
vbOKOnly + vbCritical, "Run-time Error!"
End Select
Resume tcLeft_Change_Exit
End Sub
********