VBA 调用子表单的 public 函数的语法,其中子表单是控制变量?

VBA syntax for calling a subform's public function where the subform is a control variable?

我正在尝试让表单调用其自身的子表单函数,但我不确定我应该为此使用什么语法。我的尝试如下。

在表格中:

Dim ctl As Control
For Each ctl In Me.Form
    If ctl.ControlType = acSubform And InStr(ctl.Name, "Magnets") > 0 And ctl.Name <> "UnscheduledMagnets" Then
        'THE LINE BELOW DOESN'T WORK
        Call ctl.Form.Initialize2(CalendarArray(0, 1), CalendarArray(0, 0), strQuery, CInt(Mid(ctl!Name, 1, 1)))
    End If
Next ctl

在子表单中:

Public Sub Initialize2(intDay As Integer, intDate As Long, strQuery As String, intDivision As Integer)
    'Details not important since the function isn't even being called
End Sub

谢谢!

试试这个

Form_NameOfYourSubform.Initialize2(CalendarArray(0, 1), CalendarArray(0, 0), strQuery, CInt(Mid(ctl!Name, 1, 1)))
End If

很明显,由于我自己的愚蠢,它没有起作用...我的语法没问题,但是我的一个参数引用了 ctl!Name,一个名为 Name 的表单控件不存在,而不是 ctl.Name,这是子窗体的名称。希望我可以对我原来的 post 发表评论作为我问题的答案,但我不能。