Renaming Module breaks the code (1 Viewer)

bigalpha

Registered User.
Local time
Yesterday, 17:10
Joined
Jun 22, 2012
Messages
415
Why is it when I rename a Module from 'Module1' to something different, the code I reference from that module no longer works?
 

MarkK

bit cruncher
Local time
Yesterday, 17:10
Joined
Mar 17, 2004
Messages
8,186
What kind of module is it? There are standard and class modules. A class module is essentially a datatype, so yes, if you rename it you will break code that uses it.

In a standard module you are not required to call members using the module name, but you can, so if you have a standard Module1 that has a public member, RoundToNearest(), you can call that function using this syntax . . .
Code:
dim rounded as single
rounded = Module1.RoundToNearest(22.25, 0.1)
. . . so if you rename Module1 in this case, yes, you will break that code too.

So what type of module do you mean, and what is the exact syntax of call that gets broken?
 

bigalpha

Registered User.
Local time
Yesterday, 17:10
Joined
Jun 22, 2012
Messages
415
I have some code that runs a concatenate function. I opened up the VB editor and inserted the copy and pasted code into a Module, not a Class Module. The concatenate function is called ConcatRelated.

I call this from a query using "ConcatRelated" until I change the module from 'Module1' to anything else.
 

MarkK

bit cruncher
Local time
Yesterday, 17:10
Joined
Mar 17, 2004
Messages
8,186
1) Can you be more specific about what this means . . .
the code I reference from that module no longer works
. . . please describe the exact details of the failure, for instance, does an error occur? Do you get a wrong result? "No longer works" is too vague to troubleshoot.

2) Post the SQL of the query that calls the function, so we can see the exact syntax of the call.

3) Post the code of the function itself.

I think if we can see all that stuff we should be able to tell what's going on.
 

bigalpha

Registered User.
Local time
Yesterday, 17:10
Joined
Jun 22, 2012
Messages
415
Sorry.

But I think I figured out what was happening. When I rename the module the same name as the function itself, I would get "Undefined function 'concatrelated' in expression."

When I named it anything else, it works fine. I didn't even think to rename it something other than Module1 or ConcatRelated. Must be similar to naming a text box the same name as the field it's referencing.

Sorry, I feel pretty foolish.
 

MarkK

bit cruncher
Local time
Yesterday, 17:10
Joined
Mar 17, 2004
Messages
8,186
Hey, you solved it! That's what matters.
Cheers,
 

Users who are viewing this thread

Top Bottom