以编程方式确定表单/报表是否具有宏 [英] Programmatically Determine if a Form/Report has Macros

查看:57
本文介绍了以编程方式确定表单/报表是否具有宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

祝福所有人!我已经有一段时间了 - 我出去获得了学位(英语编辑和所有事情的创意写作双重集中),然后又回到RAD开发工作,清理一堆现有的Access应用程序,并将它们按摩到一个自定义的ERP系统中。


但足够了所有这些。


我基本上是试图构建一个简单的VB函数来发现我正在讨论的许多表单/报告中有哪些嵌入了宏,所以我可以运行内在的转换。仅对需要它的实用程序,然后将我的全局错误检查代码添加到它们。显然,我可以使用HasModule方法来查看它们后面是否有代码模块,但有没有一种同样简单的方法来判断它们是否有宏?我真的不想检查每一个表格并报告。


提前致谢!

Greetings all! It''s been a while since I''ve been around - I went out and got a degree (double-concentration in English Ed and Creative Writing of all things), then went right back into a job in RAD development, cleaning up a pile of existing Access applications and massaging them into a custom ERP system.

But enough about all that.

I''m essentially trying to build a simple VB function to discover which of the many forms/reports I''m wrangling have embedded macros, so I can run the intrinsic "convert" utility only on the ones that need it, then add my global err-checking code to them. Obviously, I can use the HasModule method to see if they have code modules behind them, but is there an equally easy way to tell if they have macros? I really don''t want to check each and every form and report.

Thanks in advance!

推荐答案

Topher ,遗憾的是,Access中的宏非常值得付出努力。实施始终远远不足以适合专业工作的适当实施。当然,我很欣赏这些是你给予的东西,而不是你负责的任何东西。


Bytes专家认为这也很难过,但也是如此不时休息,不能依赖每天发布的许多帖子。我担心这是游戏的名字。你必须忍受这种限制。这是一个很好而有趣的问题,所以我会看看为你提供某种答案。


正如你正确地强调的那样,''HasModule''如果这样的对象后面有任何VBA代码,那么Form和Report对象的属性是一种方便快捷的方法。事物的宏观方面绝对不是那么精心设计的。我们需要的是一些程序,用于检查指定(表单或报表)对象中每个对象中所有事件属性的状态。


NB。请参阅下面的例外情况,其中可以从非相关模块调用代码。这可能是你感兴趣的。


第一个程序将处理对象本身和该对象的所有控件。


第二个程序将检查任何传递的对象的所有属性,如果它们是一个事件属性,检查值。可能的值类别是(参见事件属性。):

空 - 未分配。忽略。

[事件程序] - 代码。忽略。

= * - 代码(具体程序)。忽略。

别的 - 宏。


似乎没有确定的方法来确定哪些属性是事件属性,但是你可以在你的列表中列出一个列表代码来自活动和事件属性参考。我知道,不是很整洁,但可以给你你需要的东西。
Topher, It''s sad, but true, that macros in Access are very rarely worth the effort. The implementation has always been a long way short of an adequate implementation suitable for professional work. Of course, I appreciate these are something you''ve been given and not anything you''re responsible for.

It''s also sad, but true, that Bytes experts take breaks from time to time, and can''t be relied upon to see every thread of the many posted per day. I''m afraid that''s the name of the game. You have to live with that restriction. It''s a good and interesting question though so I''ll have a look at providing some sort of answer for you.

As you quite correctly highlight, the ''HasModule'' property of Form and Report objects is a handy way to tell, quickly and easily, if such an object has any VBA code behind it. The macro side of things is absolutely not so well designed. What is needed is a couple of procedures that check the status of all Event Properties in every object within the specified (Form or Report) object.

NB. See below for the exception where code can be invoked from a non-related module. This may be of interest to you.

The first procedure would handle the object itself and all controls of that object.

The second procedure would check through all the properties of any passed object and, if they are an Event Property, check the value. The possible classes of values are (See Event Properties.) :
Empty - Not assigned. Ignore.
[Event Procedure] - Code. Ignore.
=* - Code (Specific procedure). Ignore.
Anything else - Macro.

There appears to be no defined way to determine which properties are Event properties, but you can make a list in your code from Events and Event Properties Reference. Not tidy, I know, but can give you what you need.


谢谢,NeoPa,你的典型经过深思熟虑的答案。我甚至没想过要为宏触发器检查表单和控件属性。我会尝试敲打一个功能 - 如果它有效,我会把它发回到这里,以便其他人可以受益。


P.S.我以为你无所不在,无所不知,无所不能,NeoPa! ;)
Thanks, NeoPa, for your typically well-thought-out answer. I didn''t even think to check the form and control properties themselves for macro triggers. I''ll try to bang out a function for that - if it works, I''ll post it back up here so others can benefit.

P.S. I thought you were omnipresent, omniscient, and omnipotent, NeoPa! ;)


我太太了 - 但后来我发现我只是一个普通的家伙。男孩是我疯了;-(


敲出一些代码。然后,如果你有任何问题,我们可以看看它并为你找到解决方案。我希望你''我自己管理得很好; - )
Me too Topher - but then I found I was just a normal chap. Boy was I mad ;-(

Knock out some code. Then, if you have any problems with it, we can look at it and find solutions for you. I expect you''ll manage just fine by yourself though ;-)


这篇关于以编程方式确定表单/报表是否具有宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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