O
Octet32
When i try to call the fuction i get a error I am using
CalcWorkDays([DateDiverted],[dtmEnd])
The error says The expression is typed incorrectly or it too comples to be
evaluated
Does anyone know what wrong this I am a beginner VB
Function CalcWorkDays(DateDiverted As Date, dtmEnd As Date) As Integer
'Calculated the number of working days between two dates
'DateDiverted - the first day to include in the range
'dtmEnd - the last day to include in the range
'Returns the number of working days between the two dates
'Both dates are counted if they are working days
Dim intTotalDays As Integer ' Counter for number of days
Dim dtmToday As Date ' To increment the date to compare
intTotalDays = DateDiff("d", DateDiverted, dtnEnd) + 1 'Start
with total days
'Add one
to include
First Day
dtmToday = DateDiverted
'Initiate compare date
Do Until DateDiverted > dtmEnd
If WeekDay(dtmToday, vbMonday) > 5 Then 'It is Saturday or
SUNDAY
intTotalDays = intTotalDays - 1 'Take one day
away for Weekend day
ElseIf Not IsNull(DLookup("[HolidayDate]", "tblHolidays", _
"[HolidayDate] = #" & dtmToday & "#")) Then 'It is a holiday
intTotalDays = intTotalDays - 1 ‘Take one day away
for the Holiday
End If
dtmToday = DateAdd("d", 1, dtmToday) 'Add a day for next
Compare
Loop 'Until dtmToday > dtmEnd All days have been
compared
CalcWorkDays = intTotalDays 'Return the value
End Function
Thanks
Octet
CalcWorkDays([DateDiverted],[dtmEnd])
The error says The expression is typed incorrectly or it too comples to be
evaluated
Does anyone know what wrong this I am a beginner VB
Function CalcWorkDays(DateDiverted As Date, dtmEnd As Date) As Integer
'Calculated the number of working days between two dates
'DateDiverted - the first day to include in the range
'dtmEnd - the last day to include in the range
'Returns the number of working days between the two dates
'Both dates are counted if they are working days
Dim intTotalDays As Integer ' Counter for number of days
Dim dtmToday As Date ' To increment the date to compare
intTotalDays = DateDiff("d", DateDiverted, dtnEnd) + 1 'Start
with total days
'Add one
to include
First Day
dtmToday = DateDiverted
'Initiate compare date
Do Until DateDiverted > dtmEnd
If WeekDay(dtmToday, vbMonday) > 5 Then 'It is Saturday or
SUNDAY
intTotalDays = intTotalDays - 1 'Take one day
away for Weekend day
ElseIf Not IsNull(DLookup("[HolidayDate]", "tblHolidays", _
"[HolidayDate] = #" & dtmToday & "#")) Then 'It is a holiday
intTotalDays = intTotalDays - 1 ‘Take one day away
for the Holiday
End If
dtmToday = DateAdd("d", 1, dtmToday) 'Add a day for next
Compare
Loop 'Until dtmToday > dtmEnd All days have been
compared
CalcWorkDays = intTotalDays 'Return the value
End Function
Thanks
Octet