Guys, I am getting runtime error 381 could not set the list property. Invalid property array index message in the following code.
Private Sub UserForm_Initialize()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim ws1 As Worksheet
Dim j As Long
j = 0
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=J:\WorkQueue.mdb;"
Set rs = CreateObject("ADODB.Recordset")
rs.Open "select [DestroyAfter],[DestructionStatus] from MasterBatchTBL where [DestroyAfter]< #" & Format(Date, "mm/dd/yyyy") & "# and QName='4' order by DestroyAfter", cn
rs.MoveFirst
Do While Not rs.EOF
If ListBox1.ListCount = 0 Then
With ListBox1
.List(0, 0) = rs!DestroyAfter
.List(0, 1) = rs!DestructionStatus
End With
Else
With ListBox1
.List(.ListCount - 1, 0) = rs!DestroyAfter
.List(.ListCount - 1, 1) = rs!DestructionStatus
End With
End If
rs.MoveNext
Loop
rs.Close
end sub
Bookmarks