Afternoon all
I hope someone can help with this problem. I use the following code (taken from here obviously - thanks Rural Guy) to DateAdd taking into account working days and holidays - all works perfectly.
Public Function PlusWorkdays(dteStart As Date, intNumDays As Long) As Date
PlusWorkdays = dteStart
Do While intNumDays > 0
PlusWorkdays = DateAdd("d", 1, PlusWorkdays)
If Weekday(PlusWorkdays, vbMonday) <= 5 And _
IsNull(DLookup("[Holiday]", "tblHolidays", _
"[HolDate] = " & Format(PlusWorkdays, "\#mm\/dd\/yyyy\#;;;\N\u\l\l"))) Then
intNumDays = intNumDays - 1
End If
Loop
End Function
However, I need to adapt the code to subtract days from a given date. When I enter a minus figure this code returns the same day as the given date. Can someone help me out with this? Access 2002 if that matters.
I hope someone can help with this problem. I use the following code (taken from here obviously - thanks Rural Guy) to DateAdd taking into account working days and holidays - all works perfectly.
Public Function PlusWorkdays(dteStart As Date, intNumDays As Long) As Date
PlusWorkdays = dteStart
Do While intNumDays > 0
PlusWorkdays = DateAdd("d", 1, PlusWorkdays)
If Weekday(PlusWorkdays, vbMonday) <= 5 And _
IsNull(DLookup("[Holiday]", "tblHolidays", _
"[HolDate] = " & Format(PlusWorkdays, "\#mm\/dd\/yyyy\#;;;\N\u\l\l"))) Then
intNumDays = intNumDays - 1
End If
Loop
End Function
However, I need to adapt the code to subtract days from a given date. When I enter a minus figure this code returns the same day as the given date. Can someone help me out with this? Access 2002 if that matters.