Adding user-defined function

T

Tim

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
 
C

Chris

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
 
M

Manuel

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
 
D

Douglas J. Steele

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?
 
J

John Spencer (MVP)

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
 

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