Hi am trying to populate a list box based on a criteria set by another 'multi'-select list box. This is the first time i have tried to do this and put together the following code, but it is telling me that i have an 'invalid use of null' (where i try to bing back ProdURC from rs)
Can anybody help please??
Thanks!
Dim i As Integer, varItm
Dim strArray() As String
Dim x As Integer
Dim strRows As Variant
i = 0
With Me.lstCat
ReDim strArray(.ItemsSelected.Count - 1)
For Each varItm In .ItemsSelected
strArray(i) = .ItemData(varItm)
i = i + 1
Next varItm
End With
For x = 0 To i - 1
Dim rs As Recordset
Set rs = New Recordset
rs.LockType = adLockOptimistic
rs.Open "SELECT tblProduct.ProdURC, tblProduct.ProdNam, tblProduct.ProdDesc, tblProduct.ProdCat, tblProduct.ProdMotPartNum FROM tblProduct WHERE (((tblProduct.ProdCat)='" & strArray(x) & "'));", CurrentProject.Connection
rs.AddNew
Next x
If Not rs.EOF Then rs.MoveFirst
Do While Not rs.EOF
lst14.AddItem rs!ProdURC
rs.MoveNext
Loop
Can anybody help please??
Thanks!
Dim i As Integer, varItm
Dim strArray() As String
Dim x As Integer
Dim strRows As Variant
i = 0
With Me.lstCat
ReDim strArray(.ItemsSelected.Count - 1)
For Each varItm In .ItemsSelected
strArray(i) = .ItemData(varItm)
i = i + 1
Next varItm
End With
For x = 0 To i - 1
Dim rs As Recordset
Set rs = New Recordset
rs.LockType = adLockOptimistic
rs.Open "SELECT tblProduct.ProdURC, tblProduct.ProdNam, tblProduct.ProdDesc, tblProduct.ProdCat, tblProduct.ProdMotPartNum FROM tblProduct WHERE (((tblProduct.ProdCat)='" & strArray(x) & "'));", CurrentProject.Connection
rs.AddNew
Next x
If Not rs.EOF Then rs.MoveFirst
Do While Not rs.EOF
lst14.AddItem rs!ProdURC
rs.MoveNext
Loop