Does that mean the previous question is resolved. Please say so on the thread so that I can close it.Originally Posted by banavas
I would advise against using macros in a database. The only exception would be an auto-executing macro (called autoexec).I want to directly run a procedure say MsgBox("hello") from a macro 'test'.
I defined the openModule action in the macro 'test' but it does exactly what it says opens the module at procedure hello. What do I have to do to run the procedure?
Macros waste space, are restricting, and offer no scope for handling errors. If a macro fails then you just can't manage the after effects.
Okay, but to answer your question: the code in the module must be a Function and not a Sub.
You would use the RunCode method to execute the function.
i.e.
[vba]MyFunction()[/vba]
In the instance you've stated though, you can also use the MsgBox method in the macro's method list to do the message box anyway. If using a function in the MsgBox method of a macro then you must place an equals sign before the function
i.e.
[vba]=MyFunction()[/vba]