the expression you entered has a function name that microsoft acc.

D

David

I'm trying to run an expression called Mod_Kill_Old_Rtfs () useing the
RunCode Action in a Macro. I can run the expression directly from the
design view of the module with no problem. However, when I try to run it as
part of a macro I receive the following error:
"The expression you entered has a function name that microsoft acces can't
find."

I've tried going to Tools / References checking a library and then
restarting the database but this didn't work. Can you help???

rgds
David
 
N

Nikos Yannacopoulos

David,

The RunCode action can run VBA Functions, but not Subs. That is to say,
if you have saved your procedure as a Sub in a module, you need to
change it to a Function. In other words, if it looks like:

Sub Mod_Kill_Old_Rtfs()
....
....
End Sub

then change it to:

Function Mod_Kill_Old_Rtfs()
....
....
End Function

and reference it in your macro as:

Mod_Kill_Old_Rtfs()

or use the expression builder to locate it under Functions / [your
project] functions and select it from there.

By the way, is there any chance Mod_Kill_Old_Rtfs is the name of the
module the procedure is saved in, rather than the name of the procedure?
If that's the case, then make sure you call the function, not the module!

HTH,
Nikos
 
D

David

Nikos: That worked. The issue was that I had named my function the same
name as my module. The Module was named Mod_Kill_Old_Rtfs and the function
was also called Mod_Kill_Old_Rtfs(). I tried making the function called
Mod_Kill_old_rtfs() but that didn't work (guess its not case sensitive).
Then I renamed the function Kill_old_rtfs() and that worked perfectly.
Thanks again.
rgds
David

Nikos Yannacopoulos said:
David,

The RunCode action can run VBA Functions, but not Subs. That is to say,
if you have saved your procedure as a Sub in a module, you need to
change it to a Function. In other words, if it looks like:

Sub Mod_Kill_Old_Rtfs()
....
....
End Sub

then change it to:

Function Mod_Kill_Old_Rtfs()
....
....
End Function

and reference it in your macro as:

Mod_Kill_Old_Rtfs()

or use the expression builder to locate it under Functions / [your
project] functions and select it from there.

By the way, is there any chance Mod_Kill_Old_Rtfs is the name of the
module the procedure is saved in, rather than the name of the procedure?
If that's the case, then make sure you call the function, not the module!

HTH,
Nikos

I'm trying to run an expression called Mod_Kill_Old_Rtfs () useing the
RunCode Action in a Macro. I can run the expression directly from the
design view of the module with no problem. However, when I try to run it as
part of a macro I receive the following error:
"The expression you entered has a function name that microsoft acces can't
find."

I've tried going to Tools / References checking a library and then
restarting the database but this didn't work. Can you help???

rgds
David
 

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