The code is the same as counting controls in a regular form, but you need to include a .form after the subform so that it accesses it as a form and not another control.
Code:
Sub CountSubControls()
Dim ctl As Control
Dim i As Integer
For Each ctl In Forms!frmMainForm!subform.Form
i = i + 1
Next ctl
MsgBox "Total number of controls is " & i
End Sub