Hi Augustus,
Are you trying to build a cross-reference of some sort? You are correct that
the SourceObject is the property that tells you which form is used by a
subform control. How you would use it depends on what you are trying to
accomplish.
Here's some code that will give you a rather crude crossreference:
Public Sub ListFormsInSubforms()
' Comments :
' Parameters: -
' Modified : 07/31/2000 SMD
'
On Error GoTo Proc_Err
Dim dbs As DAO.Database
Dim doc As Document
Dim lngI As Long
Dim ctl As Control
Set dbs = CurrentDb
lngI = 1
For Each doc In dbs.Containers("Forms").Documents
DoCmd.OpenForm doc.Name, acDesign
For Each ctl In Forms(doc.Name).Controls
If ctl.ControlType = acSubform Then
Debug.Print doc.Name, ctl.Name, ctl.SourceObject
End If
Next ctl
lngI = lngI + 1
' yield CPU every 15th iteration
If (lngI Mod 15 = 0) Then
DoEvents
End If
DoCmd.Close acForm, Forms(doc.Name).Name, acSaveYes
Next
Proc_Exit:
Set doc = Nothing
Set dbs = Nothing
Exit Sub
Proc_Err:
MsgBox Err.Number & vbCrLf & Error$
Resume Next
End Sub