How do I refer to a general module?

G

Guest

I have code that I need to run when the database starts up. I created a
general module called relink_at_startup with the code in it in a function
called relink_text_files, and I am trying to run it from an autoexec macro.
The macro is the runcode action with relink_at_startup.relink_text_files as
the parameter.

When I try to run the macro, I get the following error: "Purchase
Requisitions can't find the name 'relink_at_startup' you entered in the
expression. You may have specified a control that wasn't on the current
object without specifying the correct form or report context."

How should I be invoking this code?

How should I be referencing
 
R

Rick Brandt

SandyR said:
I have code that I need to run when the database starts up. I
created a general module called relink_at_startup with the code in it
in a function called relink_text_files, and I am trying to run it
from an autoexec macro. The macro is the runcode action with
relink_at_startup.relink_text_files as the parameter.

When I try to run the macro, I get the following error: "Purchase
Requisitions can't find the name 'relink_at_startup' you entered in
the expression. You may have specified a control that wasn't on the
current object without specifying the correct form or report context."

How should I be invoking this code?

How should I be referencing

If it's a function use...

=FunctionName()

In your case...

=relink_text_files()
 
G

Guest

Thankyou for your reply. I just tried putting the equal sign into the
macro. Now it tells me "The expression you entered has a function name that
Purchase Requisitions can't find."
 
A

Albert D. Kallal

Are you sure it is a function, and not a sub??

Use the runcode of the maco...


eg:

runcode

parmamter:

relink()

Is your function really called relink_at_startup.relink_text_files ?

If it is actually called that, then you need

relink_at_startup.relink_text_files()

Normally, just like a form has many controls and parts to it, so does a code
module. It is a grouping of code, and in side the module, your will
typically have functions and subs. The run code is able to call a function
INSIDE one of these modules. Note that the name of the module is not really
used here, but only the function name...

If the re-link code is actually a sub, then you will have to create a public
function in code that calls the re-link code (since a macro cannot call a
sub..but ONLY a function).

eg:

Public Function MyRelink()

Call relink_text_files

end function

You then would use

MyRelink() for the parameter in the runcode action of the macro...

If relink_text_Files is a public function, then you should be able to use

relink_text_files() as the paramater for runcode.
 
R

Rick Brandt

SandyR said:
Thankyou for your reply. I just tried putting the equal sign into
the macro. Now it tells me "The expression you entered has a
function name that Purchase Requisitions can't find."

Well, if it "can't be found" that suggests that you spelled it wrong or created
a sub instead of a function.
 
D

Douglas J. Steele

Rick Brandt said:
Well, if it "can't be found" that suggests that you spelled it wrong or
created a sub instead of a function.

Or that you put the Private keyword in front of it, or that you put it in
the module associated with a form or report, rather than a stand-alone
module.
 

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