获取程序名称
我可以从程序中获取程序的名称吗?在我的错误
处理程序中,我将错误写入错误表。我想写一个名字
'写错误的程序。但是,不是使用过程名称自定义每个
错误处理程序,而是能够调用一个
系统变量或函数来提供程序名称和模块
名称。这可能吗?
Can I get the name of a procedure from within the procedure? In my error
handler, I write the error to an error table. I''d like to write the name of
the procedure that''s writing the error. But, rather than customizing each
error handler with the procedure name, it would be nice to be able to call a
system variable or function that gives me the procedure name and module
name. Is that possible?
不幸的是,VBA没有公开执行程序的名称,也没有公开名字的b $ b那个模块。
如果你不知道,你可以下载一个很棒的实用工具
来自:
www.mztools.com
为VBA选择一个。
安装。
它在VBA窗口中添加了一个工具栏。
您现在可以通过
将错误处理程序放入当前程序单击工具栏按钮。并且它是可配置的。
对于模块名称,我个人所做的是在每个模块的General Declarations部分声明一个私有常量
,并为其指定该模块的名称
,例如:
Private Const conModName =" Form_frmInvoice"
使用您的常量名称错误处理程序,您希望它传递
模块名称。当你在模块之间复制'b'b'时,这个安排根本不需要改变代码。
(你可以使用Module.Name但是在MDE中失败了。)
-
Allen Browne - 微软MVP。西澳大利亚珀斯
访问用户提示 - http:// allenbrowne .com / tips.html
回复群组,而不是mvps dot org的allenbrowne。
" Neil" < no **** @ nospam.netwrote in message
news:gt ***************** @newssvr21.news.prodigy.ne t ...
Unfortunately, VBA does not expose the name of the executing procedure, nor
the name of that module.
In case you are not aware, there is a great little utility you can download
from:
www.mztools.com
Choose the one for VBA.
Install.
It adds a toolbar to the VBA window.
You can now drop your error handler into the current procedure just by
clicking the toolbar button. And it''s configurable.
For the module name, what I personally do is to declare a private constant
in the General Declarations section of every module, and assign it the name
of that module, e.g.:
Private Const conModName = "Form_frmInvoice"
Use the constant name in your error handler where you want it to pass the
module name. This arrangement requires no change to the code at all when you
copy''n''paste procedures between modules.
(You can use Module.Name, but that fails in an MDE.)
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Neil" <no****@nospam.netwrote in message
news:gt*****************@newssvr21.news.prodigy.ne t...
我可以从程序中获取程序的名称吗?在我的错误
处理程序中,我将错误写入错误表。我想写一个名字
的'写错误的程序。但是,不是使用过程名称定制每个错误处理程序,而是能够将
调用系统变量或函数来为我提供程序名称和
模块名称。这可能吗?
Can I get the name of a procedure from within the procedure? In my error
handler, I write the error to an error table. I''d like to write the name
of the procedure that''s writing the error. But, rather than customizing
each error handler with the procedure name, it would be nice to be able to
call a system variable or function that gives me the procedure name and
module name. Is that possible?
您确实意识到您刚发布了受版权保护的材料。
''=== ============================================== ===
John Spencer
访问MVP 2002-2005,2007
健康中心项目开发和管理
马里兰大学巴尔的摩郡
''====================================== =========== ===
bobh写道:
You do realize that you just posted copyrighted material.
''================================================= ===
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
''================================================= ===
bobh wrote:
11月15日上午10点20分, "尼尔" < nos ... @ nospam.netwrote:
On Nov 15, 10:20 am, "Neil" <nos...@nospam.netwrote:
>我可以从程序中获取程序的名称吗?在我的错误
处理程序中,我将错误写入错误表。我想写出'正在编写错误的程序的名称。但是,不是使用过程名称自定义每个错误处理程序,而是能够调用一个
系统变量或函数来提供程序名称和模块名称。那可能吗?
>Can I get the name of a procedure from within the procedure? In my error
handler, I write the error to an error table. I''d like to write the name of
the procedure that''s writing the error. But, rather than customizing each
error handler with the procedure name, it would be nice to be able to call a
system variable or function that gives me the procedure name and module
name. Is that possible?
我使用的这个模块 - 最初来自Access97开发者
手册。我已经修改了一下但是它仍然可以使用它今天在我所有的XP应用程序中使用它。
bobh。
选项比较数据库
选项明确
''来自Litwin,Getz和Gilbert的Access 97 Developer's Handbook。
(Sybex)
''版权所有1997.保留所有权利。
函数adhClipboardSetText(strText As String)As Variant
''在Windows剪贴板上放置一些文字
''来自Litwin,Getz和Gilbert的Access 97 Developer's Handbook。
(Sybex)>
''版权所有1997.保留所有权利。
Public Sub adhTestClipboard()
''测试将一些文本放在剪贴板上然后阅读再次关闭
''来自Litwin,Getz和Gilbert的Access 97 Developer's Handbook。
(Sybex)
''版权所有1997.保留所有权利。
Public Sub adhReportClipboardError(ByVal int错误为整数)
''报告从剪贴板收到的错误
''来自Litwin,Getz和Gilbert的Access 97 Developer's Handbook。
公共函数adhClipboardGetText()As Variant
''获取Windows剪贴板上的一些文本
''来自Access 97 Developer'' Litwin,Getz和Gilbert的手册。
(Sybex)
''版权所有1997.保留所有权利。
''出:
Hi, there is this module I use - originaly from Access97 Developers
handbook. I have modified it a bit but it still works and I use it in
all my XP apps today.
bobh.
Option Compare Database
Option Explicit
'' From Access 97 Developer''s Handbook by Litwin, Getz, and Gilbert.
(Sybex)
'' Copyright 1997. All Rights Reserved.
Function adhClipboardSetText(strText As String) As Variant
'' Puts some text on the Windows clipboard
'' From Access 97 Developer''s Handbook by Litwin, Getz, and Gilbert.
(Sybex)
'' Copyright 1997. All Rights Reserved.
Public Sub adhTestClipboard()
'' Tests putting some text on the clipboard then reading it off again
'' From Access 97 Developer''s Handbook by Litwin, Getz, and Gilbert.
(Sybex)
'' Copyright 1997. All Rights Reserved.
Public Sub adhReportClipboardError(ByVal intError As Integer)
'' Reports an error received from the clipboard
'' From Access 97 Developer''s Handbook by Litwin, Getz, and Gilbert.
Public Function adhClipboardGetText() As Variant
'' Gets some text on the Windows clipboard
'' From Access 97 Developer''s Handbook by Litwin, Getz, and Gilbert.
(Sybex)
'' Copyright 1997. All Rights Reserved.
'' Out:
谢谢,艾伦。我记得前一段时间看过Mztools并决定不用它来获得它。我得再看看。谢谢!
Neil
" Allen Browne" < Al ********* @ SeeSig.Invalidwrote in message
news:47 ********************* ** @ per-qv1-newsreader-01.iinet.net.au ...
Thanks, Allen. I remember looking at Mztools some time ago and deciding not
to get it. I''ll have to have a second look. Thanks!
Neil
"Allen Browne" <Al*********@SeeSig.Invalidwrote in message
news:47***********************@per-qv1-newsreader-01.iinet.net.au...
不幸的是,VBA没有公开执行程序的名称,
也不是该模块的名称。
如果您不知道,有一个很棒的实用程序,你可以从
下载:
www.mztools.com
选择一个用于VBA。
安装。
它在VBA窗口中添加了一个工具栏。
您现在可以将错误处理程序放入当前程序只需按
点击工具栏按钮。并且它是可配置的。
对于模块名称,我个人所做的是在每个模块的General Declarations部分声明一个私有常量
,并为其指定该模块的
名称,例如:
Private Const conModName =" Form_frmInvoice"
使用您的常量名称错误处理程序,您希望它传递
模块名称。这种安排根本不需要更改代码,因为你在模块之间复制了''''的程序。
(你可以使用Module.Name但是在MDE中失败了。)
-
Allen Browne - 微软MVP。西澳大利亚珀斯
访问用户提示 - http:// allenbrowne .com / tips.html
回复群组,而不是mvps dot org的allenbrowne。
" Neil" < no **** @ nospam.netwrote in message
news:gt ***************** @newssvr21.news.prodigy.ne t ...
Unfortunately, VBA does not expose the name of the executing procedure,
nor the name of that module.
In case you are not aware, there is a great little utility you can
download from:
www.mztools.com
Choose the one for VBA.
Install.
It adds a toolbar to the VBA window.
You can now drop your error handler into the current procedure just by
clicking the toolbar button. And it''s configurable.
For the module name, what I personally do is to declare a private constant
in the General Declarations section of every module, and assign it the
name of that module, e.g.:
Private Const conModName = "Form_frmInvoice"
Use the constant name in your error handler where you want it to pass the
module name. This arrangement requires no change to the code at all when
you copy''n''paste procedures between modules.
(You can use Module.Name, but that fails in an MDE.)
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Neil" <no****@nospam.netwrote in message
news:gt*****************@newssvr21.news.prodigy.ne t...
>我可以从程序中获取程序的名称吗?在我的错误
处理程序中,我将错误写入错误表。我想写出'写错误的程序的名称
。但是,不是使用过程名称自定义每个错误处理程序,而是能够调用系统变量或函数来提供程序名称
和模块名称。这可能吗?
>Can I get the name of a procedure from within the procedure? In my error
handler, I write the error to an error table. I''d like to write the name
of the procedure that''s writing the error. But, rather than customizing
each error handler with the procedure name, it would be nice to be able
to call a system variable or function that gives me the procedure name
and module name. Is that possible?