Undefined Function ... in Expression

  • Thread starter Stéphane Le Tréis
  • Start date
S

Stéphane Le Tréis

Hi,
I've made a public function in an access module. when I launch this function
from Access, no problem. But when I launch it from a query in VB6, I get an
error "undefined function 'MyFunction' in expression".
I've tried to access the function from a view, it doesn't work either.
I use an ADODB connection to access my database.

How can I use my function from VB6 ?

Thank you for your help :)
 
B

Brendan Reynolds

Sorry, Stéphane, you can't. User-defined functions can only be used in
queries when the queries are executed within Access, you just can't do that
when the query is executed outside of the Access environment. If you're
interested in the background to all this, see the series of 'blog' posts at
the URL in my signature line below, but the short answer is that if you
can't do what you need using the built-in functions that are available in
queries (I'm currently working on a list of such functions) you'll need to
retrieve the data 'as is' and manipulate it in code in the 'front end'
application.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
S

Stéphane Le Tréis

OK, thank you very much for replying so fast :)
I'm currently moving my VB6 application from an Oracle DB to an Access one.
And I have 'many' functions in it... So you're telling me that there is no
way for me to 'adapt' these functions in Access ?
sob... :'-(

I'll read your 'blog' posts, but english not being my mother tongue, I'm
having a bit of a headache already ;-)

Thanks a lot again.
 
B

Brendan Reynolds

Most certainly you could adapt them in Access - if you were using Access!
:) But when you use a VB6 front end and an MDB database, you're not
actually using Access - you're using the Jet database engine.

There are many built-in functions that can be used in Jet queries. There's a
list at the following URL, but my own tests so far differ somewhat from that
list, and the list does not distinguish between functions that work both
within and outside of the Microsoft Access environment, and those that only
work within that environment, which is why I'm continuing with the tests.

http://support.microsoft.com/default.aspx?kbid=294698

You may be able to replace some of your Oracle functions with these built-in
functions, or with expressions that combine two or more built-in functions,
but you can't use *user defined* VBA functions in a Jet query when it is
executed outside of the Microsoft Access environment.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
S

Stéphane Le Tréis

Thank you once again for your time, I think I understant a bit better how
the Jet database engine works.

I'll try to rewrite my functions with the built-in ones.

Bye :)
 

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