View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
michdenis michdenis is offline
external usenet poster
 
Posts: 135
Default ADO and User function

Hi Dick,

I knew i could do this :

SELECT MyField FROM...
sVariable = ReverseText(rs.Fields(0).Value)

But because some functions like "left(), right(), Sum(), Format()
and others can be used directly in a query i wondered if i could
used a UDF. Now, i know.

Thank you.


"Dick Kusleika" a écrit dans le message de groupe de discussion :
...
On Tue, 29 Sep 2009 08:44:06 -0400, "michdenis"
wrote:

Hi,

Is it possible to employ a user fonction in a query with ADO in Excel ?

If yes, is it possible to get a few examples which syntax should i used ?

For example, this one works :
SELECT Left(MyField,2) From .... But i can't integrate a personal fonction !


No you can't do that. It is the database engine (like Jet or ACE if you're
using Access) that determines what functions are available. Jet has a
library of functions that it understands. It knows what LEFT is, but will
not know what your custom function is.

You need to bring the data in as it is, then apply your custom function to
it. If you have a function to reverse the text, you would use

SELECT MyField FROM...
sVariable = ReverseText(rs.Fields(0).Value)

rather than

SELECT ReverseText(MyField) FROM...
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com