I am using a Collection to store the variable of Type SubForm but when I go to retrieve the object, it is of type Controls. Can someone tell me why this is?
For Each ctl In Me.controls
Select Case ctl.ControlType
Case acSubform
Debug.Print "subform: " & TypeName(ctl)
If (ctl.Name = "a" Or ctl.Name = "b") Then
frmCollection.Add (ctl)
End If
End Select
Next
For Each frm In frmCollection
Debug.Print "Control: " & TypeName(frm)
Next
A subform is a type of control. Based on context,
TypeName()seems to return either the general or specific type, but I don’t understand how it makes that choice.However, you may find
TypeOfuseful to determine whether or notfrmis a subform.