Calling a Procedure from a Macro Question

G

Gary Schuldt

I read that you can call a VB procedure from a macro using the RunCode
action, but you can only call a function procedure.

Why is that? Especially since the macro ignores the return value of the
function!

It seems to naive me that, in most programming languages, functions and subs
have always been the same except for the return value provided by the
function. That gives you the economy of using a computed value directly in
an expression.

So, why can't / won't RunCode call a sub procedure?

Curious in Newbie-Land
 
M

Marshall Barton

Gary said:
I read that you can call a VB procedure from a macro using the RunCode
action, but you can only call a function procedure.

Why is that? Especially since the macro ignores the return value of the
function!

It seems to naive me that, in most programming languages, functions and subs
have always been the same except for the return value provided by the
function. That gives you the economy of using a computed value directly in
an expression.

So, why can't / won't RunCode call a sub procedure?

It's just the way it is? ;-)

I think its a matter of scope, Public functions are made
available throughout Access VBA, macros, menus/toolbars, SQL
and the expression service. Since many of those
environments can utilize expressions where a function can
appear in the middle of an expression (where a return value
is the only meaningful way to use it), and because functions
are more versatile than subs, restricting these global
entities to functions prevents misuse errors and doesn't
flood the global names list with things that can only be
used in certain situations.
 
G

Gary Schuldt

Marshall said:
. . . and doesn't
flood the global names list with things that can only be
used in certain situations.

Yeah, such as functions constructed ONLY to let you call a sub from a macro!

<g, d & r>

Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top