Wrox Home  
Search P2P Archive for: Go

  Return to Index  

activex_data_objects thread: Executing VBA code from external app via ADO


Message #1 by "Lips McBugler" <lipsmcbugler@y...> on Sat, 1 Dec 2001 12:30:59
Hi,



Using Access 2000 I have written a small VBA routine inside of standard 

module. I have also written a query that calls this routine to modify one 

of the columns in a table, ie. to strip punctuation characters from the 

column, eg.



select name, MyFunc([name])

from myTable

where name = "myname"



MyFunc is defined in Module1 as a function that currently returns its 

argument (will put in the stripping details later!), eg.



Public Function MyFunc(ByVal s As String) As String

    MyFunc = s

End Function



This all works fine if I run the query within the Access environment.



However, if I try to execute the query from ADO (within a web page or a VB 

app), I get an error saying:



[Microsoft][ODBC Microsoft Access Driver]undefined function 'MyFunc' in 

expression



If I modify my query to use a built in function, such as Lcase$(), it 

works fine.



I have also tried this without going through ODBC (using OLEDB from Visual 

Basic) without success.



So, is it actually possible to call a user-defined function from outside 

of the Access environment, and if so, how????



Any suggestions are appreciated!



Lips.



Message #2 by Nick Parker <nparker@i...> on Sat, 1 Dec 2001 06:50:07 -0600 (CST)
Sure,

    A real easy method would be to remove (i.e. - strip your column) after you 

return the recordset.







> Hi,

> 

> Using Access 2000 I have written a small VBA routine inside of standard 

> module. I have also written a query that calls this routine to modify one 

> of the columns in a table, ie. to strip punctuation characters from the 

> column, eg.

> 

> select name, MyFunc([name])

> from myTable

> where name = "myname"

> 

> MyFunc is defined in Module1 as a function that currently returns its 

> argument (will put in the stripping details later!), eg.

> 

> Public Function MyFunc(ByVal s As String) As String

>     MyFunc = s

> End Function

> 

> This all works fine if I run the query within the Access environment.

> 

> However, if I try to execute the query from ADO (within a web page or a VB 

> app), I get an error saying:

> 

> [Microsoft][ODBC Microsoft Access Driver]undefined function 'MyFunc' in 

> expression

> 

> If I modify my query to use a built in function, such as Lcase$(), it 

> works fine.

> 

> I have also tried this without going through ODBC (using OLEDB from Visual 

> Basic) without success.

> 

> So, is it actually possible to call a user-defined function from outside 

> of the Access environment, and if so, how????

> 

> Any suggestions are appreciated!

> 

> Lips.

> 

> 




$subst('Email.Unsub')

> 

> Read the future with ebooks at B&N

> http://service.bfast.com/bfast/click?

bfmid=2181&sourceid=38934667&categoryid=rn_ebooks



> 









Message #3 by Kyle Burns <kburns@c...> on Mon, 10 Dec 2001 16:06:38 -0500
Is your calling routine calling the stored query by name or actually

submitting the SQL of the query?



=================================

Kyle M. Burns, MCSD, MCT

ECommerce Technology Manager

Centra Credit Union

kburns@c...



 



>> -----Original Message-----

>> From: Nick Parker [mailto:nparker@i...]

>> Sent: Saturday, December 01, 2001 7:50 AM

>> To: ActiveX_Data_Objects

>> Subject: [activex_data_objects] Re: Executing VBA code from 

>> external app

>> via ADO

>> 

>> 

>> Sure,

>>     A real easy method would be to remove (i.e. - strip your 

>> column) after you 

>> return the recordset.

>> 

>> 

>> 

>> > Hi,

>> > 

>> > Using Access 2000 I have written a small VBA routine 

>> inside of standard 

>> > module. I have also written a query that calls this 

>> routine to modify one 

>> > of the columns in a table, ie. to strip punctuation 

>> characters from the 

>> > column, eg.

>> > 

>> > select name, MyFunc([name])

>> > from myTable

>> > where name = "myname"

>> > 

>> > MyFunc is defined in Module1 as a function that currently 

>> returns its 

>> > argument (will put in the stripping details later!), eg.

>> > 

>> > Public Function MyFunc(ByVal s As String) As String

>> >     MyFunc = s

>> > End Function

>> > 

>> > This all works fine if I run the query within the Access 

>> environment.

>> > 

>> > However, if I try to execute the query from ADO (within a 

>> web page or a VB 

>> > app), I get an error saying:

>> > 

>> > [Microsoft][ODBC Microsoft Access Driver]undefined 

>> function 'MyFunc' in 

>> > expression

>> > 

>> > If I modify my query to use a built in function, such as 

>> Lcase$(), it 

>> > works fine.

>> > 

>> > I have also tried this without going through ODBC (using 

>> OLEDB from Visual 

>> > Basic) without success.

>> > 

>> > So, is it actually possible to call a user-defined 

>> function from outside 

>> > of the Access environment, and if so, how????

>> > 

>> > Any suggestions are appreciated!

>> > 

>> > Lips.

>> > 

>> > 



>> nparker@i...


>> $subst('Email.Unsub')

>> > 

>> > Read the future with ebooks at B&N

>> > http://service.bfast.com/bfast/click?

>> bfmid=2181&sourceid=38934667&categoryid=rn_ebooks

>> 

>> > 

>> 

>> 

>> 

>> 

>> 



>> kburns@c...


>> $subst('Email.Unsub')

>> 

>> Read the future with ebooks at B&N

>> http://service.bfast.com/bfast/click?bfmid=2181&sourceid=3893

4667&categoryid=rn_ebooks


  Return to Index