"Undefined Function" when calling function in query

PaulA

Registered User.
Local time
Today, 08:20
Joined
Jul 17, 2001
Messages
416
Hi, all--

It's been a while but I'm having a basic problem in Access 2007 when calling a function in a query expression.

The function is as follows:

Option Compare Database
Public Function ddhhnn_diff(dtein As Date, dteout As Date) As String

're: http://www.access-programmers.co.uk/forums/showthread.php?t=183059
'*******************************************
'Purpose: Returns DateDiff as dd:hh:nn
'Coded by: raskew
'Input: From debug (immediate) window:
' 1) ? ddhhnn_diff(#01/01/2009 12:30:00#, #01/02/2009 16:36:30#))
'Output: 1) 01:04:06
'*******************************************
Dim x As Integer

x = DateDiff("n", dtein, dteout)
ddhhnn_diff = Format(x \ 1440, "00") & ":" & Format((x Mod 1440) \ 60, "00") & ":" & Format(x Mod 60, "00")

End Function

I call it in the following query expression: ddhhnn_diff([DateTime_1], [DateTime_2]).

I get the "Undefined Function" error when I run the query.

What have I forgotten (besides alot)?

Thanks.

Paul
 
It should be in a standard module rather than behind a form. Is it?
 
It *must* also be in a Standard Module that has a name OTHER than ddhhnn_diff! I often just name the module basFunctions.
 
It was the standard module name that did it, as you suggested.

Thanks.
 
Great! Thanks for posting back with your success.
 

Users who are viewing this thread

Back
Top Bottom