将Me关键字传递给公共函数 [英] Passing the Me Keyword to a Public Function

查看:79
本文介绍了将Me关键字传递给公共函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

A97,NT4。


我在这里看过一个这样的例子,但我不能为我的生活

找到它。如果我在表单上有很多控件都需要相同的

更新后的操作,你需要传递什么语法我。一个模块中的公众

函数?


我试过调用


公共函数libComboFilter( frmForm As Form_Form1)As String


libComboFilter = frmForm.Name

Debug.Print libComboFilter


结束函数<来自名为Form1的表单中的



libComboFilter(我)


但我收到类型不匹配错误。我没有什么特别要实现的,我只是

试图让原则正确。


谢谢。

基思。

A97, NT4.

I''ve seen an example of this posted here but I can''t for the life of me
find it. If I have a lot of controls on a form which all require the same
After Update action, what syntax do you need to pass "Me" to the public
function in a module?

I''ve tried calling

Public Function libComboFilter(frmForm As Form_Form1) As String

libComboFilter = frmForm.Name
Debug.Print libComboFilter

End Function

from a form called "Form1" with

libComboFilter (Me)

but I get a type mismatch error. I''ve nothing specific to achieve, I''m just
trying to get the principle right.

Thanks.
Keith.

推荐答案

基思,

你在钓Me.ActiveControl吗?我认为你必须将
分配给表单'代码模块中的变量,然后将

变量传递给你的函数......喜欢


Dim strCtrlName as string

Dim strFormName as string

strFormName = me.name

strCtrlName = me.activecontrol.name


X = fSomePublicFunction(strFormName,strCtrlName)


那么它是完全明确的。

Keith,
are you fishing for Me.ActiveControl? I would think you''d have to
assign that to a variable in your form''s code module and then pass the
variable to your function... Something like

Dim strCtrlName as string
Dim strFormName as string
strFormName=me.name
strCtrlName = me.activecontrol.name

X=fSomePublicFunction(strFormName,strCtrlName)

then it''s totally unambiguous.


pi ******** @ hotmail。 com 写道:
pi********@hotmail.com wrote:
基思,
你在钓Me.ActiveControl吗?我认为你必须将它分配给表单'代码模块中的变量,然后将
变量传递给你的函数......就像

将strCtrlName调暗为字符串
将strFormName调暗为字符串
strFormName = me.name
strCtrlName = me.activecontrol.name

X = fSomePublicFunction(strFormName,strCtrlName)

然后它是完全明确的。
Keith,
are you fishing for Me.ActiveControl? I would think you''d have to
assign that to a variable in your form''s code module and then pass the
variable to your function... Something like

Dim strCtrlName as string
Dim strFormName as string
strFormName=me.name
strCtrlName = me.activecontrol.name

X=fSomePublicFunction(strFormName,strCtrlName)

then it''s totally unambiguous.




我可以让它像那样工作但我可以发誓我看到了一些代码

在这里Me关键字被传递给它自己...也许我是

错了。


非常感谢您的快速回复。


基思。



Well I could make it work like that but I could have sworn I saw some code
on here where the Me keyword was passed on it''s own ... maybe I was
mistaken.

Many thanks for a speedy response.

Keith.


试试这个:


公共函数MyFunction(frmObject)

MyFunction = frmObject.Name

结束函数

这样称呼:

MyName = MyFunction(我)

-


Ken Snell

< MS ACCESS MVP>


" Keith" <柯********* @ AwayWithYerCrap.com>在消息中写道

news:Xn ************************ @ 10.15.188.42 ...
Try this:

Public Function MyFunction(frmObject)
MyFunction = frmObject.Name
End Function
Call it this way:
MyName = MyFunction(Me)
--

Ken Snell
<MS ACCESS MVP>

"Keith" <ke*********@AwayWithYerCrap.com> wrote in message
news:Xn************************@10.15.188.42...
A97,NT4。

我已经看到了这里发布的一个例子,但我不能为我的生活找到它。如果我在表单上有很多控件,这些控件都需要相同的更新后操作,那么你需要传递什么语法Me。一个模块中的公共功能?

我试过调用

公共函数libComboFilter(frmForm As Form_Form1)As String

libComboFilter = frmForm.Name
Debug.Print libComboFilter

来自名为Form1的表单的结束函数

与libComboFilter(我)

但我得到了类型不匹配错误。我没有什么特别要实现的,我只是
试图让原则正确。

谢谢。
基思。
A97, NT4.

I''ve seen an example of this posted here but I can''t for the life of me
find it. If I have a lot of controls on a form which all require the same
After Update action, what syntax do you need to pass "Me" to the public
function in a module?

I''ve tried calling

Public Function libComboFilter(frmForm As Form_Form1) As String

libComboFilter = frmForm.Name
Debug.Print libComboFilter

End Function

from a form called "Form1" with

libComboFilter (Me)

but I get a type mismatch error. I''ve nothing specific to achieve, I''m
just
trying to get the principle right.

Thanks.
Keith.



这篇关于将Me关键字传递给公共函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆