Module with custom function gives "undefined function"

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!
 
R

RoyVidar

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.
 
G

Guest

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.
 

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