jadams0173
Technical User
- Feb 18, 2005
- 1,210
I've search and read numerous posts about this error but the simple (which I know it will be) solution is still out of reach. Can someone please assist. Here is where I initalize the array. I've also put
Dim aryParts in the general declarations section
Now I want to add a row to the array and here's what I'm trying and getting the subcript out of range error on the red line.
Dim aryParts in the general declarations section
Code:
ReDim aryParts(1 To rsCBO.RecordCount, 3)
rsCBO.MoveFirst
For L = 1 To rsCBO.RecordCount
aryParts(L, 1) = rsCBO.Fields("partnumber")
aryParts(L, 2) = FormatCurrency(rsCBO.Fields("cost"), 2)
aryParts(L, 3) = rsCBO.Fields("partID")
rsCBO.MoveNext
Next L
Now I want to add a row to the array and here's what I'm trying and getting the subcript out of range error on the red line.
Code:
If chNewPart = 1 Then
a = UBound(aryPartsCost, 2) + 1
Set rs1 = New ADODB.Recordset
With rs1
rs1.Open "MasterPriceList", conn, adOpenKeyset, adLockOptimistic, adCmdTable
.AddNew
!Partnumber = txtNewPart
!cost = txtCost
.Update
End With
[red]ReDim Preserve aryPartsCost(3, a)[/red]
aryPartsCost(1, a) = aryPartsCost(1, a - 1) + 1
aryPartsCost(2, a) = txtNewPart
aryPartsCost(3, a) = txtCost
End If