Module with custom function gives "undefined function"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a module with a custom function called RoundTime:
-----------------------
Option Explicit

Function RoundTimeDown(dteTime As Date) As Date

Dim intHrs As Integer
Dim intMins As Integer

intHrs = DatePart("h", dteTime)
intMins = DatePart("n", dteTime)


If intMins > 30 Then
intMins = 30
Else
intMins = 0
End If

RoundTimeDown = TimeSerial(intHrs, intMins, 0)
End Function
---------------------------
In a query, I have the following:

RT: RoundTime([Runtime])

where the field Runtime is date/time in short time format. When I try to
run the query, I get "undefined function RoundTime in expression".

I have no missing references...what am I doing wrong???

Example: the field data is 1:05 ...if it is between 1:00-1:29, round it to
1:00...if it's 1:30-1:59, round it to 1:30. Is there easier code to do
this in a query?

Would appreciate any suggestions...and many thanks for any responses!
 
DianeF wrote in message
I have created a module with a custom function called RoundTime:
-----------------------
Option Explicit

Function RoundTimeDown(dteTime As Date) As Date

Dim intHrs As Integer
Dim intMins As Integer

intHrs = DatePart("h", dteTime)
intMins = DatePart("n", dteTime)


If intMins > 30 Then
intMins = 30
Else
intMins = 0
End If

RoundTimeDown = TimeSerial(intHrs, intMins, 0)
End Function
---------------------------
In a query, I have the following:

RT: RoundTime([Runtime])

where the field Runtime is date/time in short time format. When I
try to run the query, I get "undefined function RoundTime in
expression".

I have no missing references...what am I doing wrong???

Example: the field data is 1:05 ...if it is between 1:00-1:29, round
it to 1:00...if it's 1:30-1:59, round it to 1:30. Is there easier
code to do this in a query?

Would appreciate any suggestions...and many thanks for any responses!

You've called the function RoundTimeDown not RoundTime, if that's the
error, amend the name of the function in the query.
 
DUH!!!! Thank you...both of you!

RoyVidar said:
DianeF wrote in message
I have created a module with a custom function called RoundTime:
-----------------------
Option Explicit

Function RoundTimeDown(dteTime As Date) As Date

Dim intHrs As Integer
Dim intMins As Integer

intHrs = DatePart("h", dteTime)
intMins = DatePart("n", dteTime)


If intMins > 30 Then
intMins = 30
Else
intMins = 0
End If

RoundTimeDown = TimeSerial(intHrs, intMins, 0)
End Function
---------------------------
In a query, I have the following:

RT: RoundTime([Runtime])

where the field Runtime is date/time in short time format. When I
try to run the query, I get "undefined function RoundTime in
expression".

I have no missing references...what am I doing wrong???

Example: the field data is 1:05 ...if it is between 1:00-1:29, round
it to 1:00...if it's 1:30-1:59, round it to 1:30. Is there easier
code to do this in a query?

Would appreciate any suggestions...and many thanks for any responses!

You've called the function RoundTimeDown not RoundTime, if that's the
error, amend the name of the function in the query.
 
Back
Top