Can't find function

G

Guest

I have a program that was converted from Access 2.0 to Access 2003. I’m in
the home-stretch of getting this out the door but only have a few lingering
issues.

There is one function in a module that can’t be found, only at run-time.
There are other sections of the code that reference other functions within
the same module and work just fine. When I compile the program, this error
does not occur. It only happens when I make the selection from the menu list
in run-time. I get the following error in a message box:

“The expression you entered has a function name that Microsoft Access can't
find.â€

Then an Action Failed pop-up message box appears with 'Halt' as the only
option.

I removed the .bas file from the application and added it back in and get
the same problem. Has anyone seen this before?

Thanks in advance for your help.
 
V

Van T. Dinh

Are you sure the action related to a VBA Function or Sub?

IIRC (it has been a long time since I used Access Macro), "Halt" seems to be
associated with Macro and in this case, you need to check the actions in the
Macro. Note that a Macro action can call a VBA function ... but you need to
check and trace the Macro first ...
 
G

Guest

You code is running a macro. The macro being run is either calling a function
that does not exist or is not visible to the macro (a scoping problem).
 
G

Guest

Yes, it is running a macro. The macro calls a function in a .bas file. The
function is not declared as private and other functions within the same .bas
file get called successfully from the same macro. This is why I am stumped
as to why this one function is not recognized with VB.

By the way, the legacy code that I converted from Access 2.0 to Access2003
has these same macros and function calls and work just fine.
 
V

Van T. Dinh

I am not sure whether this will fix your problem but in the relevant Macro,
find the RunCode action and check the function name argument to make sure
you had the correct spelling of the function name.

Even if it shows the correct function name, highlight the whole argument and
delete it then hit the Delete key a few times and BackSpace key a few times
(just incase there are invisible characters). After that, re-type the
function name including the parentheses even if no function argument is
required.

That's what happened when I was asked to fix an A2000 databases (upgraded
from Access 2) about 4 years ago.
 
G

Guest

I did as you suggested, but it still does not work.

I also went to the bottom of the screen where you can see the actual
Function Name and browsed out to the Expression Builder. When I open the
Functions folder, the subsequent class modules and finally the list of
functions available to me, I can see the function in question. Even when I
select the function through this list and try again, VB can not find it in
run-time.

I’m not sure how to debug a macro and didn’t find any documentation on how
to do so, but I thought the problem was within VB.

I deleted the function from within VB, saved it, exited Access, opened the
..bas module again and pasted the function back into the code. It still does
not work.

There are six total function calls within this macro, 3 of which call the
function in question. The other three work just fine, but they call
different functions. I guess my next step is to get rid of the code
completely and write completely new code.

Thanks for your help, I really appreciate it.
 
V

Van T. Dinh

* Have you tried recompile / compact & repair?
* Have you tried the /Decompile switch?
* Try also creating a new blank database and import all objects from the
exisitng database into the new blank database.
 
G

Guest

The problem is fixed and I feel like such an idiot.

The reason it didn't work was because a module and function had the same
name. The function was in a different module. In this case, I had a module
called "Deluxe" and a function in a different module also called "Deluxe".

So in Access 2.0, the same name could be share across functions and modules
but it is not the case in Access 2003. The compiler caught this problem with
different app, but I think in that case the function and the module were
contained in the same unit.

Thank you so much for your help.
 

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