Stockwell43 said:
Dirk, I have just one other question:
I type in 7/3 and 7/17 is returned not taking out 7/4. I see something
about
SkipHolidays. Am I suppose to have a table of some sort with the holidays
listed?
Various functions for handling workday math provide different methods for
dealing with holidays. Many of them use a table of holidays. The function
dhAddWorkDaysA that I pointed you to accepts and optional array of holiday
dates, and gives an example in the comments of calling it and passing some
hard-coded holidays. Basically, the function leaves it up to you to
generate and provide an array of holidays.
One way to handle this is to have a list of holidays stored in a table, and
create function that loads that table into an array and returns the array.
For example:
'----- start of code -----
Function HolidayTableToArray(Optional fReset As Boolean) As Variant
' Written by: Dirk Goldgar, DataGnostics LLC
' You may use this code in your applications, but please leave
' the attribution unchanged.
Dim rs As DAO.Recordset
Static adtHolidays() As Date
Static fLoaded As Boolean
If fReset Then
fLoaded = False
End If
If Not fLoaded Then
Erase adtHolidays
Set rs = CurrentDb.OpenRecordset("SELECT HolidayDate FROM
tblHolidays", dbOpenSnapshot)
With rs
If Not .EOF Then
.MoveLast
.MoveFirst
End If
If .RecordCount > 0 Then
ReDim adtHolidays(.RecordCount - 1)
Do Until .EOF
adtHolidays(.AbsolutePosition) = !HolidayDate
.MoveNext
Loop
End If
.Close
End With
Set rs = Nothing
fLoaded = True
End If
HolidayTableToArray = adtHolidays
End Function
'----- end of code -----
The above code assumes you have a table named "tblHolidays", containing a
date field named "HolidayDate", and each record in that table specifies the
date of a holiday to be observed. Given such a table and the function
above, you can reference the function in your call to dhAddWorkDaysA:
=dhAddWorkDaysA(10, [OriginalDate], HolidayTableToArray())
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)