Undefined Function

S

smcash

I keep getting an error that says "Undefined Function" when I try to run my
query. My database is called ReHire.mdb

Here is my standard module:

************
Public Function ServiceYears(HireIn As Date, CalcDate As Date) As Double

If CStr(Format(HireIn, "mmdd")) < CStr(Format(CalcDate, "mmdd")) Then
ServiceYears = CInt(DateDiff("yyyy", HireIn, CalcDate)) + (DateDiff("d",
Format(HireIn, "mm/dd/" & (Year(CalcDate))), CalcDate)) / DateDiff("d",
DateSerial(Year(CalcDate) - 1, Month(CalcDate), Day(CalcDate)), CalcDate)
Else
ServiceYears = CInt(DateDiff("yyyy", HireIn, CalcDate) - 1) +
(DateDiff("d", Format([HireIn], "mm/dd/" & Year(CalcDate) - 1), CalcDate)) /
DateDiff("d", DateSerial(Year(CalcDate) - 1, Month(CalcDate), Day(CalcDate)),
CalcDate)
End If

End Function
************

Here is the field of my query:

Years_Worked: ServiceYears([DateHired],[Please Enter Vacation Calculation
Date as DD-MMM-YY])

Is there something wrong with my references, maybe? I'm running MS Access
2003 and I have the first 4 references checked:

Visual Basic For Applications
Microsoft Access 11.0 Object Library
Microsoft ActiveX Data Objects 2.1 Library
OLE Automation
 
S

Steve Schapel

Smcash,

Do you happen to have named the standard module as ServiceYears? If so,
try changing it to something else.

If this isn't the problem, we will have a look at your expressions in
the function, as you have done some unusual things there.
 

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