过程名称与模块名称相同 [英] Procedure Name Same as Module Name

查看:113
本文介绍了过程名称与模块名称相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

管理员:此帖子已从中发布的劫持问题转移结合行 - 相反的联盟。请不要在现有主题中发布新问题。


@NeoPa


创建一个Bytes帐户,告诉您这项工作仍在帮助人们2019!


这个Concat功能(标记为解决方案的功能)正是我想要的。昨天功能完美。然而,今天我收到一个错误Undefined Function'Concat''In Expression"没有改变我的代码。我创建了一个新模块并将Concat更改为Concat2并且它工作正常。我是VBA的新手,很想知道将来如何避免这种情况。


此外,在FROM子句中使用查询或子查询时,这是否有效?对我来说,这不会产生连接,但是从同一个查询创建一个表并引用它。任何建议都会很棒。

解决方案

Barmaximus,


欢迎来到字节!

< blockquote class =post_quotes>
然而,今天我收到一个错误Undefined Function'Concat''In Expression"没有改变我的代码。



您是否有机会将模块命名为Concat?这会导致DB中的一些歧义。


@twinnyfo当然我做了。更改固定此模块的名称。以前对它为什么工作正常的想法?


您可能在保存模块名称之前尝试使用它。


当你打电话 Concat 并且您有一个名为 Concat 的模块和一个具有相同名称的过程,DB不知道如何正确消除歧义。构建过程时,模块名为Module1。默认情况下 - 所以没有问题。


这些类型的问题让我在过去几个小时都摸不着头脑。现在我知道使用更好的命名约定。因此,我将模块保存为modConcat,其中包含名为Concat的过程。有些人更进一步,将函数命名为fnConcat。为了进一步防止任何歧义消除。


希望这个赫普斯!


如果还有其他头脑风暴者需要帮助,请告诉我们!

Admin: This thread was moved from a hijack question posted in Combining Rows-Opposite of Union. Please do not post new questions in existing threads.

@NeoPa

Created a Bytes account to tell you this work is still helping people in 2019!

This Concat function (the one marked as solution) was exactly what I was looking for. Function worked perfectly yesterday. However, today I''m getting an error "Undefined Function ''Concat'' In Expression" with no change in my code. I created a new module and changed Concat to Concat2 and it worked. I''m new to VBA and would love to know how to avoid this in the future.

Also, does this work when using a query or subquery in the FROM clause? For me, this yields no concatenation, but creating a table from the same query and referencing that works. Any advice would be great.

解决方案

Barmaximus,

Welcome to Bytes!

However, today I''m getting an error "Undefined Function ''Concat'' In Expression" with no change in my code.

Any chance that you named the Module "Concat"? This would cause some ambiguity within the DB.


@twinnyfo of course I did. Changing the name of the module fixed this. Any thoughts on why it worked fine previously?


You probably tried using it prior to saving the Module''s Name.

When you call Concat and you have a Module named Concat and a Procedure with the same name, the DB doesn''t know how to properly disambiguate. When you build the procedure, your Module was named "Module1" by default--so there was no issue.

These types of issues have had me scratching my head for hours in the past. Now I know to use better naming conventions. So, I would have saved the Module as "modConcat", which contained a Procedure named "Concat". Some go further and name Functions "fnConcat" to further prevent any disambiguation.

Hope this hepps!

Let us know if there are any other headscratchers you need hepp with!


这篇关于过程名称与模块名称相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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