[attach]39487[/attach]
比如说这样一个函数
FUNCTION GetParentForm(str as string) as Form
dim frm as form
for each frm in application.forms
if frm.tag=str then
set GetParentForm=frm
exit for
endif
next
end function
这个函数可以在VBA调用,但是如果在窗体的按钮
按下属性输入=GetParentForm('100')则提示找不到函数
改成如下则能调用
FUNCTION GetParentForm(str as string) as string
dim frm as form
for each frm in application.forms
if frm.tag=str then
GetParentForm=frm.tag
exit for
endif
next
end function作者: andymark 时间: 2009-9-1 14:40
public FUNCTION GetParentForm(str as string) as Form
dim frm as form
for each frm in application.forms
if frm.tag=str then
set GetParentForm=frm
exit for
endif
next
end function
还是走变通的办法,继续使用forms(n)来做!
把返回值改为string则没问题
Function GetParentForm(str As String) As String
Dim frm As Form
For Each frm In Application.Forms
If frm.Tag = str Then
GetParentForm = frm.Tag
Exit For
End If
Next
End Function
Function test1(frm As String)
MsgBox frm
End Function作者: liwen 时间: 2009-9-1 17:21
这个问题本身可以直接绕过,直接用"100"字符做参数,而将函数并入一起,窗体的代码应该还简单一点,可能ACCESS的解释执行的规则就是这样,没必要研究太深,就象在ACCESS里的查询,有一些比较复杂的查询如用docmd.runsql SQL字符相同却会得到不相同的结果.