Hi,
I tring to use an array the different catigories listed below. I got htis code work if I do it without loops, but that makes it really long, because I have a number of these. However, the problem that I am having is that it is not excepting the array in the sql statement. I know this because, in my test for the Rs state it comes back with a zero. If anyone know what I can do to make this work I would appreaciate it.
Thank you
My code:
Private Sub LoansGreaterThanZero2()
Dim Ary As Integer
Dim n As Integer
Dim L(9) As String
L(0) = "CURRENT"
L(1) = "30 DAYS"
L(2) = "60 DAYS"
L(3) = "90 DAYS"
L(4) = "120 DAYS"
L(5) = "BANKRUPTCY"
L(6) = "PRE FORECLOSURE"
L(7) = "POST FORECLOSURE"
L(8) = "Total Of FIRST PRINCIPAL BALANCE"
n = 0
For Ary = 0 To 8
On Error Resume Next 'Handles the case where the Field does not exist
Err.Number = 0
Rs.Open ("Select '" & [L] & "' FROM [tblPB_Greater_Than_0_Crosstab_Counts]"), _
Cn, adOpenKeyset, adLockOptimistic
Err.Number = 0
If Rs.State <> 1 Then GoTo NxtK
If Rs!L = 0 Then
GoTo NxtK
Else
x = 66
y = 9
Do While Not Rs.EOF
Set r1 = xl1.Range((Chr$(x) & Val))
r1 = Rs!L
y = y + 1
Rs.MoveNext
Loop
End If
Rs.Close
NxtK:
n = n + 1
Next Ary
End Sub
ITM
I tring to use an array the different catigories listed below. I got htis code work if I do it without loops, but that makes it really long, because I have a number of these. However, the problem that I am having is that it is not excepting the array in the sql statement. I know this because, in my test for the Rs state it comes back with a zero. If anyone know what I can do to make this work I would appreaciate it.
Thank you
My code:
Private Sub LoansGreaterThanZero2()
Dim Ary As Integer
Dim n As Integer
Dim L(9) As String
L(0) = "CURRENT"
L(1) = "30 DAYS"
L(2) = "60 DAYS"
L(3) = "90 DAYS"
L(4) = "120 DAYS"
L(5) = "BANKRUPTCY"
L(6) = "PRE FORECLOSURE"
L(7) = "POST FORECLOSURE"
L(8) = "Total Of FIRST PRINCIPAL BALANCE"
n = 0
For Ary = 0 To 8
On Error Resume Next 'Handles the case where the Field does not exist
Err.Number = 0
Rs.Open ("Select '" & [L] & "' FROM [tblPB_Greater_Than_0_Crosstab_Counts]"), _
Cn, adOpenKeyset, adLockOptimistic
Err.Number = 0
If Rs.State <> 1 Then GoTo NxtK
If Rs!L = 0 Then
GoTo NxtK
Else
x = 66
y = 9
Do While Not Rs.EOF
Set r1 = xl1.Range((Chr$(x) & Val))
r1 = Rs!L
y = y + 1
Rs.MoveNext
Loop
End If
Rs.Close
NxtK:
n = n + 1
Next Ary
End Sub
ITM