K
klp via AccessMonster.com
I have a Customer Order entry screen that has a due date field on it.
Currently it calls a module that I created to default to the next day, skip
holidays' and weekends'. Which works great. This field has the option to use
a calendar to select the date. However, I do not have access to this calendar
since this is an application that we purchased(we have access to all tables,
queries, forms, reports, macros, modules) excluding the calendar. What I
would like is if someone happens to select say April 6th for the due date
(which is Good Friday) an message would come up stating that it's a holiday
and to choose another date. Is this possible without using the calendar? Here
is my logic that the field calls.
****************
Public Function NextWorkDay(dtmSomeDay As Date)
Dim dtmDayOff As Date
dtmSomeDay = DateAdd("d", 1, dtmSomeDay)
Do Until IsWorkDay(dtmSomeDay)
dtmSomeDay = DateAdd("d", 1, dtmSomeDay)
Loop
NextWorkDay = dtmSomeDay
End Function
*****************
Public Function IsWorkDay(dtmSomeDay As Date) As Boolean
Dim blnWorkingDay
blnWorkingDay = Weekday(dtmSomeDay, vbMonday) < 6
If blnWorkingDay Then
blnWorkingDay = IsNull(DLookup("[HolidayDate]", "tblHolidays", _
"[HolidayDate] = #" & dtmSomeDay & "#"))
End If
IsWorkDay = blnWorkingDay
End Function
******************
Any help is well appreciated
Kim P
Currently it calls a module that I created to default to the next day, skip
holidays' and weekends'. Which works great. This field has the option to use
a calendar to select the date. However, I do not have access to this calendar
since this is an application that we purchased(we have access to all tables,
queries, forms, reports, macros, modules) excluding the calendar. What I
would like is if someone happens to select say April 6th for the due date
(which is Good Friday) an message would come up stating that it's a holiday
and to choose another date. Is this possible without using the calendar? Here
is my logic that the field calls.
****************
Public Function NextWorkDay(dtmSomeDay As Date)
Dim dtmDayOff As Date
dtmSomeDay = DateAdd("d", 1, dtmSomeDay)
Do Until IsWorkDay(dtmSomeDay)
dtmSomeDay = DateAdd("d", 1, dtmSomeDay)
Loop
NextWorkDay = dtmSomeDay
End Function
*****************
Public Function IsWorkDay(dtmSomeDay As Date) As Boolean
Dim blnWorkingDay
blnWorkingDay = Weekday(dtmSomeDay, vbMonday) < 6
If blnWorkingDay Then
blnWorkingDay = IsNull(DLookup("[HolidayDate]", "tblHolidays", _
"[HolidayDate] = #" & dtmSomeDay & "#"))
End If
IsWorkDay = blnWorkingDay
End Function
******************
Any help is well appreciated
Kim P