Adding user-defined function

  • Thread starter Thread starter Tim
  • Start date Start date
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
 
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
 
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
 
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?
 
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
 
Back
Top