C
Cam
Hello,
I created a module function code to calculate # of days between 3 dates
excluding weekend and holiday. When I put it in query, CalcDays:
calcWorkdays([StartDate],[EndDate]), it gave me a undefined function
'CalcWorkdays' in expression error. Not sure what is wrong with my code.
Function calcWorkDays(dtmStart As Date, dtmEnd As Date) As Integer
On Error GoTo CalcWorkDays_Error
calcWorkDays = DateDiff("d", dtmStart, dtmEnd) - _
(DateDiff("ww", dtmStart, dtmEnd, 7) + _
DateDiff("ww", dtmStart, dtmEnd, 1)) + 1
calcWorkDays = calcWorkDays - DCount("*", "qryHolidays",
"[CalDate]between #" _
& dtmStart & "# And #" & dtmEnd & "#")
CalcWorkDays_Exit:
On Error Resume Next
Exit Function
CalcWorkDays_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure CalcWorkDays of Module modDateFunctions"
GoTo CalcWorkDays_Exit
End Function
I created a module function code to calculate # of days between 3 dates
excluding weekend and holiday. When I put it in query, CalcDays:
calcWorkdays([StartDate],[EndDate]), it gave me a undefined function
'CalcWorkdays' in expression error. Not sure what is wrong with my code.
Function calcWorkDays(dtmStart As Date, dtmEnd As Date) As Integer
On Error GoTo CalcWorkDays_Error
calcWorkDays = DateDiff("d", dtmStart, dtmEnd) - _
(DateDiff("ww", dtmStart, dtmEnd, 7) + _
DateDiff("ww", dtmStart, dtmEnd, 1)) + 1
calcWorkDays = calcWorkDays - DCount("*", "qryHolidays",
"[CalDate]between #" _
& dtmStart & "# And #" & dtmEnd & "#")
CalcWorkDays_Exit:
On Error Resume Next
Exit Function
CalcWorkDays_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure CalcWorkDays of Module modDateFunctions"
GoTo CalcWorkDays_Exit
End Function