PDA

View Full Version : SOLVED: Run Procedure from a macro



banavas
07-16-2004, 02:09 AM
Dear Friends,

Thanks for the previous reply. I have another question though.
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?

Thanks,
G.

SJ McAbney
07-16-2004, 03:15 AM
Thanks for the previous reply.Does that mean the previous question is resolved. Please say so on the thread so that I can close it.


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?I would advise against using macros in a database. The only exception would be an auto-executing macro (called autoexec).

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.

MyFunction()

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.

=MyFunction()