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