PC Review


Reply
Thread Tools Rate Thread

Adding user-defined function

 
 
Tim
Guest
Posts: n/a
 
      4th Sep 2003
I have copied the user defined function DateDiffW(), from
the MS Knowledge base and inserted into a module within my
database. When I go to use this function in a query or
report, I get the message User-defined Function not
defined.

What are the steps that I need to take in order for a user
defined function to be recognized?

Thanks,
Tim

 
Reply With Quote
 
 
 
 
Chris
Guest
Posts: n/a
 
      5th Sep 2003
You don't have to do anything specific. Just make sure
the Function is marked as Public.

Public Function DateDiffW()


Try calling it from the debug window and see if it works.


Chris



>-----Original Message-----
>I have copied the user defined function DateDiffW(), from
>the MS Knowledge base and inserted into a module within

my
>database. When I go to use this function in a query or
>report, I get the message User-defined Function not
>defined.
>
>What are the steps that I need to take in order for a

user
>defined function to be recognized?
>
>Thanks,
>Tim
>
>.
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      5th Sep 2003
Also, make sure you didn't name the module the same as the function.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele


"Chris" <(E-Mail Removed)> wrote in message
news:24e501c3733b$79f10850$(E-Mail Removed)...
> You don't have to do anything specific. Just make sure
> the Function is marked as Public.
>
> Public Function DateDiffW()
>
>
> Try calling it from the debug window and see if it works.
>
>
> Chris
>
>
>
> >-----Original Message-----
> >I have copied the user defined function DateDiffW(), from
> >the MS Knowledge base and inserted into a module within

> my
> >database. When I go to use this function in a query or
> >report, I get the message User-defined Function not
> >defined.
> >
> >What are the steps that I need to take in order for a

> user
> >defined function to be recognized?
> >
> >Thanks,
> >Tim
> >
> >.
> >



 
Reply With Quote
 
Manuel
Guest
Posts: n/a
 
      9th Sep 2003

However, that will only work within a querydef. If you
want to call it from a Procedure, or from outside Access
through ODBC, you'll keep getting that ugly error. See
Q180810 in the Microsoft knowledge database


>-----Original Message-----
>Also, make sure you didn't name the module the same as

the function.
>
>--
>Doug Steele, Microsoft Access MVP
>http://I.Am/DougSteele
>
>
>"Chris" <(E-Mail Removed)> wrote in message
>news:24e501c3733b$79f10850$(E-Mail Removed)...
>> You don't have to do anything specific. Just make sure
>> the Function is marked as Public.
>>
>> Public Function DateDiffW()
>>
>>
>> Try calling it from the debug window and see if it

works.
>>
>>
>> Chris
>>
>>
>>
>> >-----Original Message-----
>> >I have copied the user defined function DateDiffW(),

from
>> >the MS Knowledge base and inserted into a module within

>> my
>> >database. When I go to use this function in a query or
>> >report, I get the message User-defined Function not
>> >defined.
>> >
>> >What are the steps that I need to take in order for a

>> user
>> >defined function to be recognized?
>> >
>> >Thanks,
>> >Tim
>> >
>> >.
>> >

>
>
>.
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      9th Sep 2003
It's true that it won't work calling it from outside of Access (that's
because when you're calling from outside of Access, you're strictly going
through the Jet Engine, which doesn't know anything about user-defined
functions), but why do you think it won't work calling it from a procedure?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele


"Manuel" <(E-Mail Removed)> wrote in message
news:450801c37689$b75feca0$(E-Mail Removed)...
>
> However, that will only work within a querydef. If you
> want to call it from a Procedure, or from outside Access
> through ODBC, you'll keep getting that ugly error. See
> Q180810 in the Microsoft knowledge database
>
>
> >-----Original Message-----
> >Also, make sure you didn't name the module the same as

> the function.
> >
> >--
> >Doug Steele, Microsoft Access MVP
> >http://I.Am/DougSteele
> >
> >
> >"Chris" <(E-Mail Removed)> wrote in message
> >news:24e501c3733b$79f10850$(E-Mail Removed)...
> >> You don't have to do anything specific. Just make sure
> >> the Function is marked as Public.
> >>
> >> Public Function DateDiffW()
> >>
> >>
> >> Try calling it from the debug window and see if it

> works.
> >>
> >>
> >> Chris
> >>
> >>
> >>
> >> >-----Original Message-----
> >> >I have copied the user defined function DateDiffW(),

> from
> >> >the MS Knowledge base and inserted into a module within
> >> my
> >> >database. When I go to use this function in a query or
> >> >report, I get the message User-defined Function not
> >> >defined.
> >> >
> >> >What are the steps that I need to take in order for a
> >> user
> >> >defined function to be recognized?
> >> >
> >> >Thanks,
> >> >Tim
> >> >
> >> >.
> >> >

> >
> >
> >.
> >



 
Reply With Quote
 
John Spencer (MVP)
Guest
Posts: n/a
 
      15th Oct 2003
Try changing your function so that it returns a value.

Public Function FirstTwo(x) 'where x is a public string

FirstTwo = Left(X,2)

End Function

SELECT Temp.ItemNum, FirstTwo(OtherText) as TwoChar
FROM Temp



brianscook wrote:
>
> New sub-thread: I have referenced a user-defined function from a query
> in Access. The query is calling the function properly, but I am not
> getting the return value, just a NULL value.
>
> Example:
>
> In the query I am using "Select temp.item_num, FirstTwo(other_text)
> from temp"
>
> The public FirstTwo function looks like:
>
> Public Function FirstTwo(x) 'where x is a public string
>
> Let x=Left(x,2)
>
> End Function
>
> Any clues as to how I can OR if I can retrieve the value that FirstTwo
> is changing? Remember, this is only an example of what I am doing and
> any help will be appreciated.
>
> --
> Posted via http://dbforums.com

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding help to a user defined function Diarmuid Microsoft Excel Programming 4 6th Jan 2008 05:55 PM
adding a user defined function to the library aa Microsoft Excel Discussion 5 11th Mar 2007 09:48 AM
User defined function - adding names chillihawk Microsoft Excel Programming 4 1st Jun 2006 07:54 AM
Adding documention to a user defined function Jacques Maartens Microsoft Excel Programming 1 10th Mar 2004 01:26 PM
Adding a pop-up help to a user-defined function james s shoenfelt Microsoft Excel Programming 1 26th Sep 2003 03:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:55 AM.