Ive created a new module, by simply selecting new module in the database window and ive entered the following function code:
Function HrsMinsSecs(TimeVar As Double) As Double
Dim Hrs As Long
Dim Mins As String
Dim Secs As String
If IsNull(TimeVar) Then
HrsMinsSecs = Null
Mins = Format(DatePart("n", TimeVar), "00")
Secs = Format(DatePart("s", TimeVar), "00")
Hrs = (Fix(TimeVar) * 24) + DatePart("h", TimeVar)
HrsMinsSecs = Hrs & ":" & Mins & ":" & Secs
The function is supposed to show me the correct elapsed time, when performing date calculation. As usually if the difference is more that 24 hours only part is displayed.
I need to use the function in a query but when i try use the function in the field part of the query design grid, i get the error:
Undefined function <name> in expression. (Error 3085)
This happens even though my function appears within the expression builder.
Can anyone please help? Is my code incorred or do i need to define the function elsewhere.