C
Candace
I was trying to calculate the number of days excluding
weekends and holidays. I was using the code from this site
http://www.mvps.org/access/datetime/date0012.htm
Now to read in the holidays I used this function
FillIndefArray which was taken from the KnowledgeBase then
modified
My problem is reading in the holidays. I have a table of
the holidays and I try to make it into an array, like the
example, in the function FillIndefArray.
Structure
dhCountWorkdaysA2(ByVal dtmStart As Date, ByVal dtmEnd As
Date, Optional adtmDates As Variant) As Integer
Example
dhCountWorkdaysA(#7/2/2000#, #7/5/2000#, Array(#1/1/2000#,
#7/4/2000#))
It's not processing the array and I think it's because it
has double quotations around the array like "Array
(#1/1/2000#, #7/4/2000#)". I realize this happens because
I have it declared as a variant but I don't know how to
make it stop.
Any ideas?
Candace
Function FillIndefArray()
Dim dbSample As DAO.Database
Dim rstSample As DAO.Recordset
Dim intArrayCount As Integer
Dim aryTestArray() As Variant
Dim intCounter As Long
Dim StFilter As Variant
Set dbSample = CurrentDb()
Set rstSample = dbSample.OpenRecordset("Holiday")
intArrayCount = 0
ReDim Preserve aryTestArray(0)
' Fill the array.
With rstSample
StFilter = "Array("
.MoveFirst
Do Until rstSample.EOF
If (Forms![Startup]![Last_YTD_Start] <= !
[Holiday_Stat_Date]) And (Forms![Startup]![Q4_End] >= !
[Holiday_Stat_Date]) Then
' Fill the array row with the stat date.
aryTestArray(intArrayCount) = !
[Holiday_Stat_Date]
StFilter = StFilter & "#" & !
[Holiday_Stat_Date] & "#, "
' Increase the number of elements in the array
' by one to accommodate the next record.
ReDim Preserve aryTestArray(UBound
(aryTestArray) + 1)
intArrayCount = intArrayCount + 1
End If
.MoveNext
Loop
' Remove the remaining empty array row.
ReDim Preserve aryTestArray(UBound(aryTestArray) - 1)
StFilter = Left(StFilter, Len(StFilter) - 2)
StFilter = StFilter & ")"
.Close
End With
dbSample.Close
FillIndefArray = StFilter
End Function
weekends and holidays. I was using the code from this site
http://www.mvps.org/access/datetime/date0012.htm
Now to read in the holidays I used this function
FillIndefArray which was taken from the KnowledgeBase then
modified
My problem is reading in the holidays. I have a table of
the holidays and I try to make it into an array, like the
example, in the function FillIndefArray.
Structure
dhCountWorkdaysA2(ByVal dtmStart As Date, ByVal dtmEnd As
Date, Optional adtmDates As Variant) As Integer
Example
dhCountWorkdaysA(#7/2/2000#, #7/5/2000#, Array(#1/1/2000#,
#7/4/2000#))
It's not processing the array and I think it's because it
has double quotations around the array like "Array
(#1/1/2000#, #7/4/2000#)". I realize this happens because
I have it declared as a variant but I don't know how to
make it stop.
Any ideas?
Candace
Function FillIndefArray()
Dim dbSample As DAO.Database
Dim rstSample As DAO.Recordset
Dim intArrayCount As Integer
Dim aryTestArray() As Variant
Dim intCounter As Long
Dim StFilter As Variant
Set dbSample = CurrentDb()
Set rstSample = dbSample.OpenRecordset("Holiday")
intArrayCount = 0
ReDim Preserve aryTestArray(0)
' Fill the array.
With rstSample
StFilter = "Array("
.MoveFirst
Do Until rstSample.EOF
If (Forms![Startup]![Last_YTD_Start] <= !
[Holiday_Stat_Date]) And (Forms![Startup]![Q4_End] >= !
[Holiday_Stat_Date]) Then
' Fill the array row with the stat date.
aryTestArray(intArrayCount) = !
[Holiday_Stat_Date]
StFilter = StFilter & "#" & !
[Holiday_Stat_Date] & "#, "
' Increase the number of elements in the array
' by one to accommodate the next record.
ReDim Preserve aryTestArray(UBound
(aryTestArray) + 1)
intArrayCount = intArrayCount + 1
End If
.MoveNext
Loop
' Remove the remaining empty array row.
ReDim Preserve aryTestArray(UBound(aryTestArray) - 1)
StFilter = Left(StFilter, Len(StFilter) - 2)
StFilter = StFilter & ")"
.Close
End With
dbSample.Close
FillIndefArray = StFilter
End Function