Running an Access Module

B

Brent E

Good day,

I have function titled "Excel"in an Access module . The function has no
arguments to pass in. My understanding is that an access function cannot run
on its own, but must be called from a macro, etc., to be executed.

I created a macro that uses the "RunCode" option and selected the
"Functions" in the dialogue, then browsed to the name of my database, where I
saw the "Excel" function. I double clicked on that and it placed "Excel()" in
the window. I clicked OK and saved the macro; however, when I run the macro,
I get the following error message:
The expression you entered has a function name that Microsoft Access cannot
find.

What do I need to do to resolve this? Thanks for your assistance.

Cordially,
 
K

Ken Snell \(MVP\)

The function needs to be in a regular module (not a form module), and the
function needs to be Public. Also, I would not use Excel as the function
name; too easy to confuse with EXCEL application object. Change it to
fxnExcel or something like that.

Also, be sure that the name of the regular module is not the same as any
function or subroutine in the database.
 
C

Clifford Bass

Hi Brent,

It is possible to run a function directly as long as it is in a plain
(non-form/non-report) module. If it does not have any parameters, place your
cursor anywhere inside it and click on the run triangle in the tool bar or
press F5. If it does have parameters, besides a macro you can: 1) Open up
the immediate window (View, Immediate Window) and type the function name and
any parameters and press the Enter key or 2) Create a subroutine that calls
it with the parameters and use the F5 technique in that subroutine.

Clifford Bass
 

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