I know Access forms have a property called parent
, so is there any way of referencing their children? Ideally something like:
Forms!frmParentForm.Children
I know Access forms have a property called parent
, so is there any way of referencing their children? Ideally something like:
Forms!frmParentForm.Children
You can cycle through a Form's Controls collection and determine the type of control as follows:
Dim f As Form
Set f = Forms!MyForm
Dim ctl As Control
For Each ctl In f.Controls
If TypeOf ctl Is SubForm Then
MsgBox "subform: " & ctl.Name
ElseIf TypeOf ctl Is TextBox Then
MsgBox "Textbox: " & ctl.Name
Else
' test for more control types / do something
End If
Next
All of the controls on a form are "children" of that form and can be referenced by name, as in Me.Text1
for a text box. If you're looking for forms that are children of other forms by virtue of their being used in a Subform control then you could find them by enumerating the controls on the parent form, identifying the Subform controls (.ControlType=112
), and then retrieving their .SourceObject
property values.