好的,我有这种情况,我需要动态打开一个表单,请参阅下面的代码,如果可能的话,执行该表单的已知方法。
Public Sub ShowForm(par As Form, nm As String)
DoCmd.OpenForm nm
While IsOpen(nm)
DoEvents
Wend
End Sub
并非所有表单都具有相同的方法。因此,如果可能的话,添加一个额外的可选参数来传递方法调用,可能是一个字符串值。
public sub InitItem(id as string)
....
end sub
public sub InitCategory(id as string)
....
end sub
答案 0 :(得分:1)
发疯怎么样?
Private Sub Form_Open(Cancel As Integer)
Cancel = Not BuildForm(Me.Name, True)
End Sub
Function BuildForm(strFormName, blnRS, Optional strParent = "None", _
Optional strSubname = "", Optional strParentS = "", _
Optional NameMod = "", _
Optional strFormReport = "Form") As Boolean
OpenArgs,一些注释
If Me.OpenArgs & "" = "" Then
Cancel = True
Exit Sub
End If
astrOpenArgs = Split(Me.OpenArgs, ",")