G
Guest
I have the following code in an Access 2003 form:
Dim i As Integer
Dim rstHrngLossFctrs As New ADODB.Recordset
Dim arrHrngLoss() As Variant
Dim SQLstmt As String
If Not IsNull(Me!Tnchp_Profile_ID) Then
intTnchpProfile_ID = Me![Tnchp_Profile_ID]
SQLstmt = "SELECT Hrng_Loss_Fctr_Txt FROM Hrng_Loss_Fctrs " & _
"WHERE Tnchp_Profile_ID = " & intTnchpProfile_ID & _
" ORDER BY Hrng_Loss_Fctrs_Lst_ID;"
rstHrngLossFctrs.Open SQLstmt, CurrentProject.Connection,
adOpenForwardOnly, adLockReadOnly
i = 0
With rstHrngLossFctrs
/* Subscript out of range happens here */
ReDim arrHrngLoss((.RecordCount - 1), 2)
Do Until .EOF
arrHrngLoss(i, 0) = (i + 1)
arrHrngLoss(i, 1) = ![Hrng_Loss_Fctr_Txt]
.MoveNext
i = i + 1
Loop
.Close
End With
Set rsHrngLossFctrs = Nothing
I get a Subscript out of range error on the ReDim statement. The array is a
two dimentional array
Dim i As Integer
Dim rstHrngLossFctrs As New ADODB.Recordset
Dim arrHrngLoss() As Variant
Dim SQLstmt As String
If Not IsNull(Me!Tnchp_Profile_ID) Then
intTnchpProfile_ID = Me![Tnchp_Profile_ID]
SQLstmt = "SELECT Hrng_Loss_Fctr_Txt FROM Hrng_Loss_Fctrs " & _
"WHERE Tnchp_Profile_ID = " & intTnchpProfile_ID & _
" ORDER BY Hrng_Loss_Fctrs_Lst_ID;"
rstHrngLossFctrs.Open SQLstmt, CurrentProject.Connection,
adOpenForwardOnly, adLockReadOnly
i = 0
With rstHrngLossFctrs
/* Subscript out of range happens here */
ReDim arrHrngLoss((.RecordCount - 1), 2)
Do Until .EOF
arrHrngLoss(i, 0) = (i + 1)
arrHrngLoss(i, 1) = ![Hrng_Loss_Fctr_Txt]
.MoveNext
i = i + 1
Loop
.Close
End With
Set rsHrngLossFctrs = Nothing
I get a Subscript out of range error on the ReDim statement. The array is a
two dimentional array