MS-Access module function call from VB 
Author Message
 MS-Access module function call from VB

Hi,

I'm looking for a possibility to call a function defined
in a MS-Access DB module from a VB program using ADO.

I tried to call this function from within a query of the
database which works fine if executed from Access but
delivers 'unknown function' when executed via ADO from a
VB program. Some ideas ?

Thanks

Ewald



Mon, 19 Sep 2005 19:45:04 GMT  
 MS-Access module function call from VB
Hi Ewald,

No, you cannot call user-defined function from VB. Provider will not allow
to do that. What you could try to do is to store your query, which calls
user-defined function, in Access and call it from VB same way as we call
stored procedures. In that case you will not pass any user-defined function
names in your query string to provider. It may work

--
Val Mazur
Microsoft MVP



Quote:
> Hi,

> I'm looking for a possibility to call a function defined
> in a MS-Access DB module from a VB program using ADO.

> I tried to call this function from within a query of the
> database which works fine if executed from Access but
> delivers 'unknown function' when executed via ADO from a
> VB program. Some ideas ?

> Thanks

> Ewald



Mon, 19 Sep 2005 20:29:28 GMT  
 MS-Access module function call from VB

Hi Val,

unfortunately it did not work in a query called by a VB
program. I get an "Undefined function 'MyModule' in
expression" error. The query works fine if called directly
from Access.

The query looked like:
  SELECT MyModule() AS Test FROM TestTable;

And the VB code:
  With dbCmd
    .ActiveConnection = dbCon
    .CommandType = adCmdStoredProc
    .CommandText = "Query2"
    Set rst = .Execute
  End With

Ewald K. Rieger

Quote:
>-----Original Message-----
>Hi Ewald,

>No, you cannot call user-defined function from VB.

Provider will not allow
Quote:
>to do that. What you could try to do is to store your
query, which calls
>user-defined function, in Access and call it from VB same
way as we call
>stored procedures. In that case you will not pass any

user-defined function
Quote:
>names in your query string to provider. It may work

>--
>Val Mazur
>Microsoft MVP


message

>> Hi,

>> I'm looking for a possibility to call a function defined
>> in a MS-Access DB module from a VB program using ADO.

>> I tried to call this function from within a query of the
>> database which works fine if executed from Access but
>> delivers 'unknown function' when executed via ADO from a
>> VB program. Some ideas ?

>> Thanks

>> Ewald

>.



Mon, 19 Sep 2005 21:14:14 GMT  
 MS-Access module function call from VB
Hi,

So you cannot do that. This is a limitation. You would need to get data to
the client side and do rest of staff in VB on client side

--
Val Mazur
Microsoft MVP



Quote:

> Hi Val,

> unfortunately it did not work in a query called by a VB
> program. I get an "Undefined function 'MyModule' in
> expression" error. The query works fine if called directly
> from Access.

> The query looked like:
>   SELECT MyModule() AS Test FROM TestTable;

> And the VB code:
>   With dbCmd
>     .ActiveConnection = dbCon
>     .CommandType = adCmdStoredProc
>     .CommandText = "Query2"
>     Set rst = .Execute
>   End With

> Ewald K. Rieger

> >-----Original Message-----
> >Hi Ewald,

> >No, you cannot call user-defined function from VB.
> Provider will not allow
> >to do that. What you could try to do is to store your
> query, which calls
> >user-defined function, in Access and call it from VB same
> way as we call
> >stored procedures. In that case you will not pass any
> user-defined function
> >names in your query string to provider. It may work

> >--
> >Val Mazur
> >Microsoft MVP


> message

> >> Hi,

> >> I'm looking for a possibility to call a function defined
> >> in a MS-Access DB module from a VB program using ADO.

> >> I tried to call this function from within a query of the
> >> database which works fine if executed from Access but
> >> delivers 'unknown function' when executed via ADO from a
> >> VB program. Some ideas ?

> >> Thanks

> >> Ewald

> >.



Mon, 19 Sep 2005 21:27:32 GMT  
 MS-Access module function call from VB


Hi Val,

unfortunately it did not work in a query called by a VB
program. I get an "Undefined function 'MyModule' in
expression" error. The query works fine if called directly
from Access.

The query looked like:
  SELECT MyModule() AS Test FROM TestTable;

And the VB code:
  With dbCmd
    .ActiveConnection = dbCon
    .CommandType = adCmdStoredProc
    .CommandText = "Query2"
    Set rst = .Execute
  End With

Ewald K. Rieger

You can only use the VBA functions designated in the "sandbox" when run running Jet queries outside
of Access. User definied functions are not supported.

ACC2002: Jet 4.0 Expression Can Execute Unsafe Visual Basic for Applications Functions
http://support.microsoft.com/default.aspx?scid=kb;en-us;294698


Microsoft MVP (Visual Basic)



Mon, 19 Sep 2005 23:25:45 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Calling a Function in an MS Access Class/Form/Module from an outside application

2. Calling MS Access Module from VB

3. calling/running MS Access module from ASP pages

4. Accessing an MS-Access module from VB code

5. Call module functions from outside of module?

6. Calling a C function from a VB module

7. Calling a function in MS word in Access

8. MS Access v2 Pathworks function call Help !!!

9. Command button won't make use of module driving MS Project from MS Access 2000

10. calling access querydef that calls a user defined access function

11. Running MS Access Module from VB

12. Running MS Access Module from VB

 

 
Powered by phpBB® Forum Software