Accessing functions from an external library

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone:

I am trying to put most of my functions and procedures in an external MDE
and reference it through the library. I can seem to see the reference for my
external MDE library in the code window and can access it by using the syntax
library.Module.function. However when trying to reference them within query
(and a Macro) Access it cannot find reference to this library.

Does anyone know how to successfully accomplish this, or have any other way
to properly have procedures accessed externally. Any suggestion would be
helpful.

Thanks,
David
 
Hi.
I can seem to see the reference for my
external MDE library in the code window and can access it by using the syntax
library.Module.function. However when trying to reference them within query
(and a Macro) Access it cannot find reference to this library.

Make the library function a public function and call it from the current
database query. For example, if the library function were named
"getNewValue( )" and expected one formal parameter, then the following SQL
syntax would use the value returned from this function and alias this value
as "NewValue":

SELECT ID, SomeField, getNewValue(SomeField) AS NewValue
FROM MyTable;

And don't use macros. Convert the macros to VBA procedures and have those
procedures call your library functions.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Hi 69 Camero:
Wonder what kind of car you drive.

Ok, thanks for writing back.

I have tested one query. I have checked to make sure the function in my
module in my external MDE are indeed public and they are. What next, do I
have to create functions in my main application module which calls the
functions in my external MDE?
like
Function Function1Call(param)
Call function1(param)
End Function

I did something similar for my Macros.

Thanks for your assistance so far. If anyone else has any other
suggestions, that would be great.

Cheers,
David
 
Hi, David.
I have tested one query. I have checked to make sure the function in my
module in my external MDE are indeed public and they are.

Are you using a standard module or a class module in the library database?
If it's not a standard module, then you'll need to take some extra steps, or
modify the code, and/or use an older version of Access to make the public
function public to external applications. It's no go for Access 2002 and
2003 class modules in a library MDE database file, so you'll need a public
function in a standard module when using these two versions, or else modified
code for public functions in form and report modules.

Does the code in your current database compile? Make sure that it does and
that there aren't any missing references.

Are there any procedures in a module with the same name in either the
current database file or the library? No procedure can have the same name as
a module.

Are there any procedures in the current database named the same as
procedures in the library database? The current database procedure will be
used instead of the library database procedure. Developers commonly name
library procedures with a prefix such as "lib" or "wz" to avoid identical
names in other databases that may use the library database.

If there are multiple MDE database files involved, make sure that all MDE
database files in the chain have no missing references nor any other problems
that would prevent dependent database files from working properly.
What next, do I
have to create functions in my main application module which calls the
functions in my external MDE?
No.

I did something similar for my Macros.

If you're advanced enough to use library databases, then you no longer have
macros. You've already converted them to VBA procedures, complete with error
handling.

If you've followed all of the rules I've described above and still can't get
the query in the current database to recognize the library database's
function, then please post the SQL statement calling this library function,
post the formal parameters for the function, and post the name of the library
module and the type of module containing the function, because there's
probably something wrong with the syntax you are using. And let us know
which version of Access you are using, which database format the current
database is in, and which database format the library database is in, because
one of these factors may be interfering with what you are trying to do.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 

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

Back
Top