Here is my code so far:
I am getting an error at .List(I,0) = rst![PurchID] (Run-time error '424' Object Required)
Any ideas what I'm doing wrong?
Code:
Private Sub UserForm_Initialize()
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim i As Integer
cnn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=Forecast;Data Source=sqlaxrpt;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=BRIANBECK-LT;Use Encryption for Data=False;Tag with column collation when possible=False"
rst.Open "SELECT [PurchID], [ITEMID], [INVENTSITEID], [REMAINPURCHPHYSICAL], [DELIVERYDATE] FROM PurchasingTable WHERE ItemID = 'K3930903';", cnn, adOpenStatic ', adLockUnspecified
rst.MoveFirst
i = 0
With Me.ListBox1
.ColumnCount = 5
.ColumnWidths = "50;50;50;50;50"
.Clear
Do
.AddItem
.List(i, 0) = rst![PurchID]
.List(i, 1) = rst![ItemID]
.List(i, 2) = rst![INVENTSITEID]
.List(i, 3) = rst![REMAINPURCHPHYSICAL]
.List(i, 4) = rst![DELIVERYDATE]
i = i + 1
rst.MoveNext
Loop Until rst.EOF
End With
End Sub
I am getting an error at .List(I,0) = rst![PurchID] (Run-time error '424' Object Required)
Any ideas what I'm doing wrong?