how to execute a module from a macro? (1 Viewer)

Sleekmac

Registered User.
Local time
Today, 18:30
Joined
Sep 25, 2006
Messages
34
I have a large macro that calls a bunch of queries, and somewhere in the middle I need to put a piece of VBA code that is stored in a module.
So my macro looks like this:
openQuery
openQuery
openQuery
openQuery
openModule
openQuery
openQuery
openQuery

The module is a blend of select and action queries with loops, etc. all taking place on a table contained in the database. When I run the macro, it is not executing the Sub in the module. I'm trying to decipher the MS Access help, and it looks like the openModule function only opens the module in Design mode, which I cannot think of one real-world application for. How do I go about opening the module and then Running it?
Thanks in advance,
Don
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 15:30
Joined
Aug 30, 2003
Messages
36,129
Try using RunCode
 

Sleekmac

Registered User.
Local time
Today, 18:30
Joined
Sep 25, 2006
Messages
34
runCode seems to be looking for a function rather than a sub. Is this as simple as creating a function in another module that in turn calls the sub?
Can you suggest an easy way to create a public function that points to a sub? Sorry, I am pretty new to VBA, so pretty clueless.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 15:30
Joined
Aug 30, 2003
Messages
36,129
You can probably just change the sub to a function. It would need to be public, in a standard module.
 

Sleekmac

Registered User.
Local time
Today, 18:30
Joined
Sep 25, 2006
Messages
34
You are a frickin genius! Thanks again. :)
 

Users who are viewing this thread

Top Bottom