C
Candace
In the function FillIndefArray below, when I run it the
code runs through but I get inaccurate results. When I
traced through the code I discovered that for the lines
with aryTestArray(intArrayCount) it says <subscript out of
range>
How do I fix that? Is it not recognizing the end of file?
Candace
*********************************************
Function FillIndefArray()
Dim dbSample As DAO.Database
Dim rstSample As DAO.Recordset
Dim intArrayCount As Integer
Dim aryTestArray() As Variant
Set dbSample = CurrentDb()
Set rstSample = dbSample.OpenRecordset("Holiday")
intArrayCount = 0
' Fill the array.
With rstSample
.MoveFirst
Do Until rstSample.EOF
If (Forms![Startup]![Last_YTD_Start] <= !
[Holiday_Stat_Date]) And (Forms![Startup]![Q4_End] >= !
[Holiday_Stat_Date]) Then
'Make place for the start date and
' fill it with the start date in SQL format.
ReDim Preserve aryTestArray(intArrayCount)
aryTestArray(intArrayCount) = !
[Holiday_Stat_Date]
' Increase the array index for the next
Redim
intArrayCount = intArrayCount + 1
End If
.MoveNext
Loop
.Close
End With
'Return the array with dates
FillIndefArray = aryTestArray
End Function
code runs through but I get inaccurate results. When I
traced through the code I discovered that for the lines
with aryTestArray(intArrayCount) it says <subscript out of
range>
How do I fix that? Is it not recognizing the end of file?
Candace
*********************************************
Function FillIndefArray()
Dim dbSample As DAO.Database
Dim rstSample As DAO.Recordset
Dim intArrayCount As Integer
Dim aryTestArray() As Variant
Set dbSample = CurrentDb()
Set rstSample = dbSample.OpenRecordset("Holiday")
intArrayCount = 0
' Fill the array.
With rstSample
.MoveFirst
Do Until rstSample.EOF
If (Forms![Startup]![Last_YTD_Start] <= !
[Holiday_Stat_Date]) And (Forms![Startup]![Q4_End] >= !
[Holiday_Stat_Date]) Then
'Make place for the start date and
' fill it with the start date in SQL format.
ReDim Preserve aryTestArray(intArrayCount)
aryTestArray(intArrayCount) = !
[Holiday_Stat_Date]
' Increase the array index for the next
Redim
intArrayCount = intArrayCount + 1
End If
.MoveNext
Loop
.Close
End With
'Return the array with dates
FillIndefArray = aryTestArray
End Function